Skip to content

Commit a08076a

Browse files
author
Mladen Rusev
committed
* add comment to README
* add venctl and step as tools * reduce log level * add controls based on MR labels
1 parent 6c411e4 commit a08076a

File tree

5 files changed

+80
-28
lines changed

5 files changed

+80
-28
lines changed

.github/workflows/tests.yaml

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ jobs:
6565
- run: make -j test-unit test-helm
6666

6767
test-e2e:
68+
if: contains(github.event.pull_request.labels.*.name, 'test-e2e')
6869
runs-on: ubuntu-latest
6970
steps:
7071
- uses: actions/checkout@v4
@@ -74,6 +75,7 @@ jobs:
7475
- uses: ./.github/actions/repo_access
7576
with:
7677
DEPLOY_KEY_READ_VENAFI_CONNECTION_LIB: ${{ secrets.DEPLOY_KEY_READ_VENAFI_CONNECTION_LIB }}
78+
7779
- name: Authenticate to Google Cloud
7880
id: auth
7981
uses: google-github-actions/auth@v2
@@ -84,35 +86,53 @@ jobs:
8486
id: setup-gcloud
8587
uses: google-github-actions/setup-gcloud@v2
8688
with:
89+
install_components: "gke-gcloud-auth-plugin"
8790
project_id: machineidentitysecurity-jsci-e
8891

8992
- name: Configure Docker for Google Artifact Registry
9093
run: gcloud auth configure-docker europe-west1-docker.pkg.dev
9194

92-
- name: Install dependencies
93-
run: |
94-
gcloud components install gke-gcloud-auth-plugin
95-
curl -sSfL https://dl.venafi.cloud/venctl/latest/installer.sh | bash
96-
echo "/home/runner/.venafi/bin" >> $GITHUB_PATH
97-
curl -LO https://github.com/smallstep/cli/releases/latest/download/step-cli_amd64.deb
98-
sudo apt-get install ./step-cli_amd64.deb
99-
helm plugin install https://github.com/databus23/helm-diff
100-
10195
- id: go-version
10296
run: |
10397
make print-go-version >> "$GITHUB_OUTPUT"
10498
10599
- uses: actions/setup-go@v5
106100
with:
107101
go-version: ${{ steps.go-version.outputs.result }}
108-
- run: make -j test-e2e-gke
102+
103+
- name: Generate timestamp for cluster name
104+
id: timestamp # Give the step an ID to reference its output
105+
run: |
106+
# Generate a timestamp in the format YYMMDD-HHMMSS.
107+
# Extracting from PR name would require sanitization due to GKE cluster naming constraints
108+
TIMESTAMP=$(date +'%y%m%d-%H%M%S')
109+
CLUSTER_NAME="test-secretless-${TIMESTAMP}"
110+
echo "Generated cluster name: ${CLUSTER_NAME}"
111+
echo "cluster_name=${CLUSTER_NAME}" >> $GITHUB_OUTPUT
112+
113+
- run: |
114+
make helm-plugins
115+
make -j test-e2e-gke
116+
# The VEN_API_KEY_PULL secret is set to my API key (Mladen) for glow.in.the.dark tenant.
109117
env:
110118
VEN_API_KEY: ${{ secrets.VEN_API_KEY_PULL }}
111119
VEN_API_KEY_PULL: ${{ secrets.VEN_API_KEY_PULL }}
112120
OCI_BASE: europe-west1-docker.pkg.dev/machineidentitysecurity-jsci-e/js-agent-ci-repo
113121
VEN_API_HOST: api.venafi.cloud
114-
VEN_ZONE: mladen-test\Default
122+
VEN_ZONE: k8s-agent-CI\Default
115123
VEN_VCP_REGION: us
116124
CLOUDSDK_CORE_PROJECT: machineidentitysecurity-jsci-e
117125
CLOUDSDK_COMPUTE_ZONE: europe-west1-b
118-
CLUSTER_NAME: test-secretless
126+
CLUSTER_NAME: ${{ steps.timestamp.outputs.cluster_name }}
127+
128+
- name: Delete GKE Cluster
129+
# 'always()' - Run this step regardless of success or failure.
130+
# '!contains(...)' - AND only run if the list of PR labels DOES NOT contain 'keep-e2e-cluster'.
131+
# NOTE: You will have to delete the test cluster manually when finished with debugging or incur costs.
132+
if: always() && !contains(github.event.pull_request.labels.*.name, 'keep-e2e-cluster')
133+
run: |
134+
echo "Label 'keep-e2e-cluster' not found. Cleaning up GKE cluster ${{ steps.timestamp.outputs.cluster_name }}"
135+
gcloud container clusters delete ${{ steps.timestamp.outputs.cluster_name }} \
136+
--project=${{ secrets.GCP_PROJECT_ID }} \
137+
--zone=europe-west1-b \
138+
--quiet

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,10 @@ The following metrics are collected:
5656
- Go collector: via the [default registry](https://github.com/prometheus/client_golang/blob/34e02e282dc4a3cb55ca6441b489ec182e654d59/prometheus/registry.go#L60-L63) in Prometheus `client_golang`.
5757
- Process collector: via the [default registry](https://github.com/prometheus/client_golang/blob/34e02e282dc4a3cb55ca6441b489ec182e654d59/prometheus/registry.go#L60-L63) in Prometheus `client_golang`.
5858
- Agent metrics: `data_readings_upload_size`: Data readings upload size (in bytes) sent by the in-cluster agent.
59+
60+
## End to end testing
61+
62+
An end to end test script is available in the [./hack/e2e/test.sh](./hack/e2e/test.sh) directory. It is configured to run in CI
63+
in the tests.yaml GitHub Actions workflow. To run the script you will need to add the `test-e2e` label to the PR.
64+
The script creates a cluster in GKE and cleanups after itself unless the `keep-e2e-cluster` label is set on the PR. Adding that
65+
label will leave the cluster running for further debugging but it will incur costs so manually delete the cluster when done.

hack/e2e/values.venafi-kubernetes-agent.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ authentication:
1010

1111
extraArgs:
1212
- --logging-format=json
13-
- --log-level=6
13+
- --log-level=4

make/02_mod.mk

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ shared_generate_targets += generate-crds-venconn
5151
## Wait for it to log a message indicating successful data upload.
5252
## See `hack/e2e/test.sh` for the full test script.
5353
## @category Testing
54-
test-e2e-gke:
55-
./hack/e2e/test.sh
54+
test-e2e-gke: | $(NEEDS_HELM) $(NEEDS_STEP) $(NEEDS_VENCTL)
55+
PATH="$(bin_dir)/tools:${PATH}" ./hack/e2e/test.sh
5656

5757
.PHONY: test-helm
5858
## Run `helm unittest`.
@@ -66,6 +66,15 @@ test-helm: | $(NEEDS_HELM-UNITTEST)
6666
test-helm-snapshot: | $(NEEDS_HELM-UNITTEST)
6767
$(HELM-UNITTEST) ./deploy/charts/venafi-kubernetes-agent/ -u
6868

69+
.PHONY: helm-plugins
70+
## Install required helm plugins
71+
helm-plugins: $(NEEDS_HELM)
72+
@if ! $(HELM) plugin list | grep -q diff; then \
73+
echo ">>> Installing helm-diff plugin"; \
74+
$(HELM) plugin install https://github.com/databus23/helm-diff; \
75+
else \
76+
echo "helm-diff plugin already installed"; \
77+
fi
6978

7079
.PHONY: verify-govulncheck
7180
## Verify all Go modules for vulnerabilities using govulncheck Copied from makefile-modules

make/_shared/tools/00_mod.mk

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
1-
# Copyright 2023 The cert-manager Authors.
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
1+
142

153
ifndef bin_dir
164
$(error bin_dir is not set)
@@ -636,6 +624,34 @@ $(DOWNLOAD_DIR)/tools/operator-sdk@$(OPERATOR-SDK_VERSION)_$(HOST_OS)_$(HOST_ARC
636624
$(checkhash_script) $(outfile) $(operator-sdk_$(HOST_OS)_$(HOST_ARCH)_SHA256SUM); \
637625
chmod +x $(outfile)
638626

627+
# https://docs.venafi.cloud/vaas/venctl/c-venctl-releases/
628+
venctl_linux_amd64_SHA256SUM=26e7b7a7e134f1cf1f3ffacf4ae53ec6849058db5007ce4088d51f404ededb4a
629+
venctl_darwin_amd64_SHA256SUM=2e76693901abcb2c018f66d3a10558c66ca09d1a3be912258bcd6c58e89aae80
630+
venctl_darwin_arm64_SHA256SUM=4350912d67683773302655e2a0151320514d1ccf82ee99c895e6780f86b6f031
631+
632+
.PRECIOUS: $(DOWNLOAD_DIR)/tools/venctl@$(VENCTL_VERSION)_$(HOST_OS)_$(HOST_ARCH)
633+
$(DOWNLOAD_DIR)/tools/venctl@$(VENCTL_VERSION)_$(HOST_OS)_$(HOST_ARCH): | $(DOWNLOAD_DIR)/tools
634+
@source $(lock_script) $@; \
635+
$(CURL) https://dl.venafi.cloud/venctl/$(VENCTL_VERSION)/venctl-$(HOST_OS)-$(HOST_ARCH).zip -o $(outfile).zip; \
636+
$(checkhash_script) $(outfile).zip $(venctl_$(HOST_OS)_$(HOST_ARCH)_SHA256SUM); \
637+
unzip -p $(outfile).zip venctl > $(outfile); \
638+
chmod +x $(outfile); \
639+
rm -f $(outfile).zip
640+
641+
# https://github.com/smallstep/cli/releases/
642+
step_linux_amd64_SHA256SUM=2908f3c7d90181eec430070b231da5c0861e37537bf8e2388d031d3bd6c7b8c6
643+
step_linux_arm64_SHA256SUM=96636a6cc980d53a98c72aa3b99e04f0b874a733d9ddf43fc6b0f1725f425c37
644+
step_darwin_amd64_SHA256SUM=f6e9a9078cfc5f559c8213e023df6e8ebf8d9d36ffbd82749a41ee1c40a23623
645+
step_darwin_arm64_SHA256SUM=b856702ee138a9badbe983e88758c0330907ea4f97e429000334ba038597db5b
646+
647+
.PRECIOUS: $(DOWNLOAD_DIR)/tools/step@$(STEP_VERSION)_$(HOST_OS)_$(HOST_ARCH)
648+
$(DOWNLOAD_DIR)/tools/step@$(STEP_VERSION)_$(HOST_OS)_$(HOST_ARCH): | $(DOWNLOAD_DIR)/tools
649+
@source $(lock_script) $@; \
650+
$(CURL) https://dl.smallstep.com/gh-release/cli/gh-release-header/v$(STEP_VERSION)/step_$(HOST_OS)_$(STEP_VERSION)_$(HOST_ARCH).tar.gz -o $(outfile).tar.gz; \
651+
$(checkhash_script) $(outfile).tar.gz $(step_$(HOST_OS)_$(HOST_ARCH)_SHA256SUM); \
652+
tar xfO $(outfile).tar.gz step_$(STEP_VERSION)/bin/step > $(outfile); \
653+
chmod +x $(outfile); \
654+
rm -f $(outfile).tar.gz
639655
#################
640656
# Other Targets #
641657
#################

0 commit comments

Comments
 (0)