Skip to content

Commit 8a765ef

Browse files
authored
Merge pull request #552 from jetstack/venconn
Add support for the VenafiConnection CRD so that users can start using the Workload Identity Federation authentication ("secretless")
2 parents 5a8004c + 9b0e619 commit 8a765ef

28 files changed

+5004
-397
lines changed

.github/workflows/release-master.yml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,46 @@ jobs:
1111
vet:
1212
name: vet
1313
runs-on: ubuntu-22.04
14-
container: golang:1.19
14+
container: golang:1.22
1515
steps:
16+
- name: "Add GitHub to the SSH known hosts file"
17+
run: |
18+
mkdir -p -m 0700 /root/.ssh
19+
cat <<EOF >/root/.ssh/known_hosts
20+
github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl
21+
github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=
22+
github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=
23+
EOF
24+
chmod 600 /root/.ssh/known_hosts
25+
touch /root/.ssh/config
26+
- uses: webfactory/[email protected]
27+
with:
28+
ssh-private-key: ${{ secrets.DEPLOY_KEY_READ_VENAFI_CONNECTION_LIB }}
1629
- uses: actions/checkout@v4
1730
- run: make vet
1831
shell: bash
1932
test:
2033
name: go test
2134
runs-on: ubuntu-22.04
22-
container: golang:1.19
35+
container: golang:1.22
2336
steps:
37+
- name: "Add GitHub to the SSH known hosts file"
38+
run: |
39+
mkdir -p -m 0700 /root/.ssh
40+
cat <<EOF >/root/.ssh/known_hosts
41+
github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl
42+
github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=
43+
github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=
44+
EOF
45+
chmod 600 /root/.ssh/known_hosts
46+
touch /root/.ssh/config
47+
- uses: webfactory/[email protected]
48+
with:
49+
ssh-private-key: ${{ secrets.DEPLOY_KEY_READ_VENAFI_CONNECTION_LIB }}
2450
- uses: actions/checkout@v4
51+
- name: Adding github workspace as safe directory
52+
# See issue https://github.com/actions/checkout/issues/760
53+
run: git config --global --add safe.directory $GITHUB_WORKSPACE
2554
- run: make test
2655
docker_build:
2756
name: docker_build
@@ -41,6 +70,9 @@ jobs:
4170
packages: write
4271
id-token: write
4372
steps:
73+
- uses: webfactory/[email protected]
74+
with:
75+
ssh-private-key: ${{ secrets.DEPLOY_KEY_READ_VENAFI_CONNECTION_LIB }}
4476
- name: Install Tools
4577
# Installing 'bash' because it's required by the 'cosign-installer' action
4678
# and 'coreutils' because the 'slsa-provenance-action' requires a version

.github/workflows/test.yml

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,63 @@ on:
99
branches:
1010
- "*"
1111

12+
env:
13+
GOPRIVATE: github.com/jetstack/venafi-connection-lib
14+
1215
jobs:
1316
vet:
1417
name: vet
1518
runs-on: ubuntu-22.04
16-
container: golang:1.19
19+
container: golang:1.22
1720
steps:
1821
- uses: actions/checkout@v4
22+
# The only reason we need to configure ~/.ssh/known_hosts is because we are
23+
# using a container-based runner. Non-container runners already have the
24+
# github.com fingerprints in their known_hosts file. We could use `curl
25+
# --silent https://api.github.com/meta` to fetch it but golang:1.22 does not
26+
# have jq installed.
27+
#
28+
# Remember that the container "golang:1.22.0" has two "homes": /root is the
29+
# home returned by getent(), which is what the GitHub Action and SSH will
30+
# use to load .ssh/config and keys under .ssh/, and $HOME is /github/home,
31+
# which is where Git loads ~/.gitconfig from.
32+
- name: "Add GitHub to the SSH known hosts file"
33+
run: |
34+
mkdir -p -m 0700 /root/.ssh
35+
cat <<EOF >/root/.ssh/known_hosts
36+
github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl
37+
github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=
38+
github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=
39+
EOF
40+
chmod 600 /root/.ssh/known_hosts
41+
touch /root/.ssh/config
42+
- uses: webfactory/[email protected]
43+
with:
44+
ssh-private-key: ${{ secrets.DEPLOY_KEY_READ_VENAFI_CONNECTION_LIB }}
1945
- run: make vet
2046
shell: bash
2147
test:
2248
name: go test
2349
runs-on: ubuntu-22.04
24-
container: golang:1.19
50+
container: golang:1.22
2551
steps:
52+
- name: "Add GitHub to the SSH known hosts file"
53+
run: |
54+
mkdir -p -m 0700 /root/.ssh
55+
cat <<EOF >/root/.ssh/known_hosts
56+
github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl
57+
github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=
58+
github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=
59+
EOF
60+
chmod 600 /root/.ssh/known_hosts
61+
touch /root/.ssh/config
62+
- uses: webfactory/[email protected]
63+
with:
64+
ssh-private-key: ${{ secrets.DEPLOY_KEY_READ_VENAFI_CONNECTION_LIB }}
2665
- uses: actions/checkout@v4
66+
- name: Adding github workspace as safe directory
67+
# See issue https://github.com/actions/checkout/issues/760
68+
run: git config --global --add safe.directory $GITHUB_WORKSPACE
2769
- run: make test
2870
docker_build:
2971
name: docker_build
@@ -41,6 +83,9 @@ jobs:
4183
steps:
4284
- name: Install Tools
4385
run: apk add --update make git jq rsync curl
86+
- uses: webfactory/[email protected]
87+
with:
88+
ssh-private-key: ${{ secrets.DEPLOY_KEY_READ_VENAFI_CONNECTION_LIB }}
4489
- name: Adding github workspace as safe directory
4590
# See issue https://github.com/actions/checkout/issues/760
4691
run: git config --global --add safe.directory $GITHUB_WORKSPACE

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ predicate.json
1313
*.pub
1414
*.tgz
1515

16+
_bin

Makefile

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ GOVERSION:=$(shell go version | awk '{print $$3 " " $$4}')
77
GOOS:=$(shell go env GOOS)
88
GOARCH:=$(shell go env GOARCH)
99

10+
export GOPRIVATE=github.com/jetstack/venafi-connection-lib
11+
1012
BIN_NAME:=preflight
1113

1214
DOCKER_IMAGE?=quay.io/jetstack/preflight
@@ -48,6 +50,8 @@ build:
4850
install:
4951
cd $(ROOT_DIR) && $(GO_INSTALL)
5052

53+
export KUBEBUILDER_ASSETS=$(ROOT_DIR)/_bin/tools
54+
test: _bin/tools/etcd _bin/tools/kube-apiserver
5155
test:
5256
cd $(ROOT_DIR) && go test ./...
5357

@@ -73,11 +77,13 @@ build-all-platforms-in-host:
7377

7478
build-all-platforms-in-docker:
7579
rm -rf ./builds
76-
docker build --rm -t preflight-bin -f ./builder.dockerfile \
80+
docker buildx build --load --rm -t preflight-bin -f ./builder.dockerfile \
7781
--build-arg oauth_client_id=$(OAUTH_CLIENT_ID) \
7882
--build-arg oauth_client_secret=$(OAUTH_CLIENT_SECRET) \
7983
--build-arg oauth_auth_server_domain=$(OAUTH_AUTH_SERVER_DOMAIN) \
84+
--ssh default \
8085
.
86+
docker rm -f preflight-bin-container 2>/dev/null || true
8187
docker create --rm --name=preflight-bin-container preflight-bin
8288
docker cp preflight-bin-container:/go/github.com/jetstack/preflight/builds ./builds
8389
docker rm preflight-bin-container
@@ -142,3 +148,54 @@ ci-build: ci-test build build-docker-image build-all-platforms bundle-all-platfo
142148

143149
ci-publish: ci-build push-docker-image
144150
echo "ci-publish is going to be disabled. We are adopting Github actions"
151+
152+
# NOTE(mael): The download targets for yq, etcd, and kube-apiserver are a lesser
153+
# and suboptimal version of what's in venafi-enhanced-issuer. We will migrate to
154+
# makefile-modules and klone soon, so I didn't want to work too hard on this.
155+
156+
YQ_linux_amd64_SHA256SUM=bd695a6513f1196aeda17b174a15e9c351843fb1cef5f9be0af170f2dd744f08
157+
YQ_darwin_amd64_SHA256SUM=b2ff70e295d02695b284755b2a41bd889cfb37454e1fa71abc3a6ec13b2676cf
158+
YQ_darwin_arm64_SHA256SUM=e9fc15db977875de982e0174ba5dc2cf5ae4a644e18432a4262c96d4439b1686
159+
YQ_VERSION=v4.35.1
160+
161+
_bin/downloaded/tools/yq@$(YQ_VERSION)_%:
162+
mkdir -p _bin/downloaded/tools
163+
curl -L https://github.com/mikefarah/yq/releases/download/$(YQ_VERSION)/yq_$* -o $@
164+
./make/util/checkhash.sh $@ $(YQ_$*_SHA256SUM)
165+
chmod +x $@
166+
167+
HOST_OS=$(shell uname | tr '[:upper:]' '[:lower:]')
168+
HOST_ARCH=$(shell uname -m | sed 's/x86_64/amd64/')
169+
170+
_bin/tools/yq: _bin/downloaded/tools/yq@$(YQ_VERSION)_$(HOST_OS)_$(HOST_ARCH)
171+
@mkdir -p _bin/tools
172+
@cd $(dir $@) && ln -sf $(patsubst _bin/%,../%,$<) $(notdir $@)
173+
174+
KUBEBUILDER_TOOLS_linux_amd64_SHA256SUM=f9699df7b021f71a1ab55329b36b48a798e6ae3a44d2132255fc7e46c6790d4d
175+
KUBEBUILDER_TOOLS_darwin_amd64_SHA256SUM=e1913674bacaa70c067e15649237e1f67d891ba53f367c0a50786b4a274ee047
176+
KUBEBUILDER_TOOLS_darwin_arm64_SHA256SUM=0422632a2bbb0d4d14d7d8b0f05497a4d041c11d770a07b7a55c44bcc5e8ce66
177+
KUBEBUILDER_ASSETS_VERSION=1.27.1
178+
179+
_bin/downloaded/tools/etcd@$(KUBEBUILDER_ASSETS_VERSION)_%: _bin/downloaded/tools/kubebuilder_tools_$(KUBEBUILDER_ASSETS_VERSION)_%.tar.gz | _bin/downloaded/tools
180+
./make/util/checkhash.sh $< $(KUBEBUILDER_TOOLS_$*_SHA256SUM)
181+
@# O writes the specified file to stdout
182+
tar xfO $< kubebuilder/bin/etcd > $@ && chmod 775 $@
183+
184+
_bin/downloaded/tools/kube-apiserver@$(KUBEBUILDER_ASSETS_VERSION)_%: _bin/downloaded/tools/kubebuilder_tools_$(KUBEBUILDER_ASSETS_VERSION)_%.tar.gz | _bin/downloaded/tools
185+
./make/util/checkhash.sh $< $(KUBEBUILDER_TOOLS_$*_SHA256SUM)
186+
@# O writes the specified file to stdout
187+
tar xfO $< kubebuilder/bin/kube-apiserver > $@ && chmod 775 $@
188+
189+
_bin/downloaded/tools/kubebuilder_tools_$(KUBEBUILDER_ASSETS_VERSION)_$(HOST_OS)_$(HOST_ARCH).tar.gz: | _bin/downloaded/tools
190+
curl -L https://storage.googleapis.com/kubebuilder-tools/kubebuilder-tools-$(KUBEBUILDER_ASSETS_VERSION)-$(HOST_OS)-$(HOST_ARCH).tar.gz -o $@
191+
192+
_bin/downloaded/tools:
193+
@mkdir -p $@
194+
195+
_bin/tools/etcd: _bin/downloaded/tools/etcd@$(KUBEBUILDER_ASSETS_VERSION)_$(HOST_OS)_$(HOST_ARCH)
196+
@mkdir -p _bin/tools
197+
@cd $(dir $@) && ln -sf $(patsubst _bin/%,../%,$<) $(notdir $@)
198+
199+
_bin/tools/kube-apiserver: _bin/downloaded/tools/kube-apiserver@$(KUBEBUILDER_ASSETS_VERSION)_$(HOST_OS)_$(HOST_ARCH)
200+
@mkdir -p _bin/tools
201+
@cd $(dir $@) && ln -sf $(patsubst _bin/%,../%,$<) $(notdir $@)

builder.dockerfile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1-
FROM golang:1.21.6 as builder
1+
FROM golang:1.22.5 as builder
22

33
WORKDIR /go/github.com/jetstack/preflight
44

55
# Run a dependency resolve with just the go mod files present for
66
# better caching
7-
COPY ./go.mod .
8-
COPY ./go.sum .
7+
COPY go.mod go.sum .
98

10-
RUN go mod download
9+
COPY <<EOF /root/.gitconfig
10+
[url "[email protected]:jetstack/venafi-connection-lib"] \
11+
insteadOf = https://github.com/jetstack/venafi-connection-lib
12+
EOF
13+
COPY <<EOF /root/.ssh/known_hosts
14+
github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl
15+
github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=
16+
github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=
17+
EOF
18+
ENV GOPRIVATE=github.com/jetstack/venafi-connection-lib
19+
20+
RUN --mount=type=ssh go mod download
1121

1222
## Bring in everything else
1323
COPY . .
@@ -22,7 +32,6 @@ RUN make build-all-platforms \
2232
OAUTH_CLIENT_SECRET=${oauth_client_secret} \
2333
OAUTH_AUTH_SERVER_DOMAIN=${oauth_auth_server_domain}
2434

25-
2635
RUN go install github.com/google/[email protected]
2736

2837
# We need this '|| true' because go-licenses could fail to find a license so

cmd/agent.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,24 @@ func init() {
138138
os.Getenv("API_TOKEN"),
139139
"Token used for authentication when API tokens are in use on the backend",
140140
)
141+
agentCmd.PersistentFlags().StringVar(
142+
&agent.VenConnName,
143+
"venafi-connection",
144+
"",
145+
"Name of the VenafiConnection to be used. Using this flag will enable the VenafiConnection mode.",
146+
)
147+
agentCmd.PersistentFlags().StringVar(
148+
&agent.VenConnNS,
149+
"venafi-connection-namespace",
150+
"",
151+
"Namespace of the VenafiConnection to be used. It is only useful when the VenafiConnection isn't in the same namespace as the agent. The field `allowReferencesFrom` must be present on the cross-namespace VenafiConnection for the agent to use it.",
152+
)
153+
agentCmd.PersistentFlags().StringVar(
154+
&agent.InstallNS,
155+
"install-namespace",
156+
"",
157+
"Namespace in which the agent is running. Only needed when running the agent outside of Kubernetes. Used for testing purposes.",
158+
)
141159
agentCmd.PersistentFlags().BoolVarP(
142160
&agent.Profiling,
143161
"enable-pprof",

0 commit comments

Comments
 (0)