Skip to content

Commit c226989

Browse files
authored
Chart compatible with TLSPK VCP auth (#466)
* feat: basic chart for TLS protect agent auth setup * feat: Use new config options * docs: Update readme and tests * chore: cleanup unused files * feat: Update CI to test both charts * fix: Unittesting CI * docs: fix a few minor issues and enhance helm readme * docs: Include EU variant example plus run spell checker --------- Signed-off-by: Peter Fiddes <[email protected]>
1 parent a1b618c commit c226989

File tree

16 files changed

+1117
-8
lines changed

16 files changed

+1117
-8
lines changed

.github/workflows/chart-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
- uses: d3adb5/helm-unittest-action@v2
1717
with:
1818
flags: "--color --strict"
19-
charts: deploy/charts/jetstack-agent
2019
helm-version: v3.12.3
2120
# This has to be second as helm may not be installed until after above action
2221
# source: https://github.com/marketplace/actions/helm-unit-tests#examples
2322
- run: helm lint deploy/charts/jetstack-agent
23+
- run: helm lint deploy/charts/venafi-kubernetes-agent

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ terraform.tfstate
99
terraform.tfstate.backup
1010
bom.xml
1111
predicate.json
12-
privatekey.pem
12+
*.pem
13+
*.pub
14+
*.tgz
1315

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/norwoodj/helm-docs
3-
rev: v1.11.0
3+
rev: v1.11.3
44
hooks:
55
- id: helm-docs
66
args:

deploy/charts/jetstack-agent/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,19 @@ kubectl logs -n jetstack-secure $(kubectl get pod -n jetstack-secure -l app.kube
139139
| authentication.secretValue | string | `""` | Base64 encoded value from Jetstack Secure Dashboard - only required when createSecret is true |
140140
| authentication.type | string | `"file"` | Type can be "file"/"token" determining how the agent should authenticate the to the backend |
141141
| command | list | `[]` | |
142-
| config | object | `{"cluster":"","dataGatherers":{"custom":[],"default":true},"organisation":"","override":{"config":"","configmap":{"key":"","name":""},"enabled":false},"period":"0h1m0s","server":"https://platform.jetstack.io"}` | Configuration section for the Jetstack Agent itself |
142+
| config | object | `{"cluster":"","dataGatherers":{"custom":[],"default":true},"organisation":"","override":{"config":null,"configmap":{"key":null,"name":null},"enabled":false},"period":"0h1m0s","server":"https://platform.jetstack.io"}` | Configuration section for the Jetstack Agent itself |
143143
| config.cluster | string | `""` | REQUIRED - Your Jetstack Secure Cluster Name |
144144
| config.dataGatherers | object | `{"custom":[],"default":true}` | Configure data that is gathered from your cluster, for full details see https://platform.jetstack.io/documentation/configuration/jetstack-agent/configuration |
145145
| config.dataGatherers.custom | list | `[]` | A list of data gatherers to limit agent scope |
146146
| config.dataGatherers.default | bool | `true` | Use the standard full set of data gatherers |
147147
| config.organisation | string | `""` | REQUIRED - Your Jetstack Secure Organisation Name |
148-
| config.override | object | `{"config":"","configmap":{"key":"","name":""},"enabled":false}` | Provide an Override to allow completely custom agent configuration |
149-
| config.override.config | string | `""` | Embed the agent configuration here in the chart values |
150-
| config.override.configmap | object | `{"key":"","name":""}` | Sepcify ConfigMap details to load config from existing ConfigMap |
148+
| config.override | object | `{"config":null,"configmap":{"key":null,"name":null},"enabled":false}` | Provide an Override to allow completely custom agent configuration |
149+
| config.override.config | string | `nil` | Embed the agent configuration here in the chart values |
150+
| config.override.configmap | object | `{"key":null,"name":null}` | Sepcify ConfigMap details to load config from existing ConfigMap |
151151
| config.override.enabled | bool | `false` | Override disabled by default |
152152
| config.period | string | `"0h1m0s"` | Send data back to the platform every minute unless changed |
153153
| config.server | string | `"https://platform.jetstack.io"` | Overrides the server if using a proxy between agent and Jetstack Secure |
154+
| extraArgs | list | `[]` | |
154155
| fullnameOverride | string | `""` | Helm default setting, use this to shorten install name |
155156
| image.pullPolicy | string | `"IfNotPresent"` | Defaults to only pull if not already present |
156157
| image.repository | string | `"quay.io/jetstack/preflight"` | Default to Open Source image repository |
@@ -175,4 +176,4 @@ kubectl logs -n jetstack-secure $(kubectl get pod -n jetstack-secure -l app.kube
175176
| tolerations | list | `[]` | |
176177

177178
----------------------------------------------
178-
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
179+
Autogenerated from chart metadata using [helm-docs v1.11.3](https://github.com/norwoodj/helm-docs/releases/v1.11.3)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v2
2+
name: venafi-kubernetes-agent
3+
description: |-
4+
The Venafi Kubernetes Agent connects your Kubernetes or Openshift cluster to the Venafi Control Plane.
5+
type: application
6+
version: 0.1.0
7+
appVersion: "v0.1.43"
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# venafi-kubernetes-agent
2+
3+
The Venafi Kubernetes Agent connects your Kubernetes or Openshift cluster to the Venafi Control Plane.
4+
5+
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.1.43](https://img.shields.io/badge/AppVersion-v0.1.43-informational?style=flat-square)
6+
7+
## Additional Information
8+
9+
The Venafi Kubernetes Agent connects your Kubernetes or OpenShift cluster to the Venafi Control Plane.
10+
You will require a Venafi Control Plane account to connect your cluster.
11+
If you do not have you, you can sign up for a free trial now at:
12+
- https://venafi.com/try-venafi/tls-protect/
13+
14+
Note that there are EU and US Venafi Control Plane options.
15+
Upon signing up you will be redirected to one of either of the following login URLs:
16+
- https://ui.venafi.cloud/ (US)
17+
- https://ui.venafi.eu/ (EU)
18+
19+
## Installation:
20+
21+
Using chart installation, there are two credentials required.
22+
23+
1) A registry credential to allow helm to pull the chart from our private OCI registry.
24+
2) A service account key pair used by the agent to authenticate to the Venafi Control Plane.
25+
26+
### 1) Setup registry credentials
27+
28+
The helm chart is an OCI chart artifact hosted on both EU and US registries:
29+
30+
- `oci://eu.gcr.io/jetstack-secure-enterprise/charts/venafi-kubernetes-agent`
31+
- `oci://us.gcr.io/jetstack-secure-enterprise/charts/venafi-kubernetes-agent`
32+
33+
More detailed instructions on how to access our registry are available in [this guide](https://platform.jetstack.io/documentation/installation/enterprise-registry).
34+
35+
For chart installation, run the following to set a registry configuration
36+
file, so `helm` can authenticate to our private OCI registry:
37+
38+
```shell
39+
export VENAFI_DOCKER_CONFIG_PATH="$(pwd)"
40+
export VENAFI_DOCKER_CONFIG_FILE="${TLSPK_DOCKER_CONFIG_PATH}/config.json"
41+
jsctl registry auth output --format=dockerconfig > "${VENAFI_DOCKER_CONFIG_FILE}"
42+
```
43+
44+
To validate you registry credentials are working with `helm`, we can use it to
45+
show us the full list of values available to configure the chart:
46+
47+
```shell
48+
export VENAFI_REGISTRY="eu.gcr.io/jetstack-secure-enterprise"
49+
helm show values oci://${VENAFI_REGISTRY}/charts/venafi-kubernetes-agent \
50+
--registry-config "${VENAFI_DOCKER_CONFIG_FILE}"
51+
```
52+
53+
**Note**: Feel free to alter the registry to the US equivalent if that is closer to you.
54+
For example: `export VENAFI_REGISTRY="us.gcr.io/jetstack-secure-enterprise"`
55+
56+
### 2) Creating Venafi Service Account:
57+
58+
First we need to create an OpenSSL key pair and save the private key securely.
59+
The private key is used by the agent and you should have a unique key for each agent you connect to the Venafi Control Plane.
60+
The public key will be added to the Venafi Control Plane as the service account credential and assigned to the appropriate team for ownership.
61+
62+
```shell
63+
export VENAFI_NAMESPACE="venafi" VENAFI_SERVICE_ACCOUNT="example-cluster"
64+
openssl genrsa -out ${VENAFI_SERVICE_ACCOUNT}.pem
65+
openssl rsa -in ${VENAFI_SERVICE_ACCOUNT}.pem -pubout --out ${VENAFI_SERVICE_ACCOUNT}.pub
66+
```
67+
68+
Now that you have both the private and public key we now need to use the Venafi Control Plane to create a service account.
69+
70+
- Navigate to the [service accounts page](https://ui.venafi.cloud/service-accounts/) and select "New"
71+
- Add a unique name matching the variable we used, eg: "example-cluster"
72+
- Assign a team that owns this credential
73+
- The scope should be "Kubernetes Discovery" only.
74+
- Set the validity period of your pubic key up to a maximum of 365 days.
75+
- Now paste in the **public key** from the pair you generated.
76+
77+
Once created, you will be returned to the service accounts list.
78+
Find your newest entry matching the name you entered, and copy the "Client ID" column.
79+
80+
### 3) Deploying the chart:
81+
82+
Now we have the service account, let us prepare a namespace with the relevant private key needed at runtime.
83+
84+
```shell
85+
export VENAFI_CLIENT_ID="<PASTE YOURS HERE>"
86+
kubectl create namespace ${VENAFI_NAMESPACE}
87+
kubectl create secret generic agent-credentials -n ${VENAFI_NAMESPACE} \
88+
--from-file=privatekey.pem=${VENAFI_SERVICE_ACCOUNT}.pem
89+
```
90+
91+
Install the chart by setting the `config.clientId` field:
92+
93+
```shell
94+
helm upgrade --install venafi-kubernetes-agent deploy/charts/venafi-kubernetes-agent \
95+
--namespace ${VENAFI_NAMESPACE} \
96+
--set config.clientId="${VENAFI_CLIENT_ID}"
97+
```
98+
99+
Optionally if you need to change the backend to the EU Venafi Control Plane you can use:
100+
101+
```shell
102+
export VENAFI_SERVER_URL="https://api.venafi.eu/"
103+
helm upgrade --install venafi-kubernetes-agent deploy/charts/venafi-kubernetes-agent \
104+
--namespace ${VENAFI_NAMESPACE} \
105+
--set config.clientId="${VENAFI_CLIENT_ID}" \
106+
--set config.server="${VENAFI_SERVER_URL}"
107+
```
108+
109+
### 4) Add Cluster in Venafi Control Plane
110+
111+
- Go to "Installations" -> "Kubernetes Clusters" [here](https://ui.venafi.cloud/clusters-inventory) and click "Connect". **Note** you may need to click [here](https://ui.venafi.eu/clusters-inventory) for the EU backend.
112+
- On step 1 select "Continue".
113+
- On step 2 select "Advanced Connection".
114+
- On step 3 select "Continue" to skip.
115+
- On step 4, fill in the details as needed:
116+
- "Name" should match your service account name from before, e.g. "example-cluster".
117+
- Under "Service Account" click that drop down and select the previously created service account.
118+
- Then check the "The connection command has completed." box and select "continue".
119+
- On step 5, either wait for validation or select "Finish" to go back to the cluster list.
120+
121+
### 5) Deployment Verification
122+
123+
Check the agent logs to ensure you see a similar entry to the following:
124+
125+
```console
126+
2023/10/24 12:10:03 Running Agent...
127+
2023/10/24 12:10:03 Posting data to: https://api.venafi.cloud/
128+
2023/10/24 12:10:04 Data sent successfully.
129+
```
130+
131+
You can do this with the following command:
132+
133+
```shell
134+
kubectl logs -n ${VENAFI_NAMESPACE} $(kubectl get pod -n ${VENAFI_NAMESPACE} -l app.kubernetes.io/instance=
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
{{ template "chart.header" . }}
2+
{{ template "chart.description" . }}
3+
4+
{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }}
5+
6+
## Additional Information
7+
8+
The Venafi Kubernetes Agent connects your Kubernetes or OpenShift cluster to the Venafi Control Plane.
9+
You will require a Venafi Control Plane account to connect your cluster.
10+
If you do not have you, you can sign up for a free trial now at:
11+
- https://venafi.com/try-venafi/tls-protect/
12+
13+
Note that there are EU and US Venafi Control Plane options.
14+
Upon signing up you will be redirected to one of either of the following login URLs:
15+
- https://ui.venafi.cloud/ (US)
16+
- https://ui.venafi.eu/ (EU)
17+
18+
## Installation:
19+
20+
Using chart installation, there are two credentials required.
21+
22+
1) A registry credential to allow helm to pull the chart from our private OCI registry.
23+
2) A service account key pair used by the agent to authenticate to the Venafi Control Plane.
24+
25+
### 1) Setup registry credentials
26+
27+
The helm chart is an OCI chart artifact hosted on both EU and US registries:
28+
29+
- `oci://eu.gcr.io/jetstack-secure-enterprise/charts/venafi-kubernetes-agent`
30+
- `oci://us.gcr.io/jetstack-secure-enterprise/charts/venafi-kubernetes-agent`
31+
32+
More detailed instructions on how to access our registry are available in [this guide](https://platform.jetstack.io/documentation/installation/enterprise-registry).
33+
34+
For chart installation, run the following to set a registry configuration
35+
file, so `helm` can authenticate to our private OCI registry:
36+
37+
```shell
38+
export VENAFI_DOCKER_CONFIG_PATH="$(pwd)"
39+
export VENAFI_DOCKER_CONFIG_FILE="${TLSPK_DOCKER_CONFIG_PATH}/config.json"
40+
jsctl registry auth output --format=dockerconfig > "${VENAFI_DOCKER_CONFIG_FILE}"
41+
```
42+
43+
To validate you registry credentials are working with `helm`, we can use it to
44+
show us the full list of values available to configure the chart:
45+
46+
```shell
47+
export VENAFI_REGISTRY="eu.gcr.io/jetstack-secure-enterprise"
48+
helm show values oci://${VENAFI_REGISTRY}/charts/venafi-kubernetes-agent \
49+
--registry-config "${VENAFI_DOCKER_CONFIG_FILE}"
50+
```
51+
52+
**Note**: Feel free to alter the registry to the US equivalent if that is closer to you.
53+
For example: `export VENAFI_REGISTRY="us.gcr.io/jetstack-secure-enterprise"`
54+
55+
### 2) Creating Venafi Service Account:
56+
57+
First we need to create an OpenSSL key pair and save the private key securely.
58+
The private key is used by the agent and you should have a unique key for each agent you connect to the Venafi Control Plane.
59+
The public key will be added to the Venafi Control Plane as the service account credential and assigned to the appropriate team for ownership.
60+
61+
```shell
62+
export VENAFI_NAMESPACE="venafi" VENAFI_SERVICE_ACCOUNT="example-cluster"
63+
openssl genrsa -out ${VENAFI_SERVICE_ACCOUNT}.pem
64+
openssl rsa -in ${VENAFI_SERVICE_ACCOUNT}.pem -pubout --out ${VENAFI_SERVICE_ACCOUNT}.pub
65+
```
66+
67+
Now that you have both the private and public key we now need to use the Venafi Control Plane to create a service account.
68+
69+
- Navigate to the [service accounts page](https://ui.venafi.cloud/service-accounts/) and select "New"
70+
- Add a unique name matching the variable we used, eg: "example-cluster"
71+
- Assign a team that owns this credential
72+
- The scope should be "Kubernetes Discovery" only.
73+
- Set the validity period of your pubic key up to a maximum of 365 days.
74+
- Now paste in the **public key** from the pair you generated.
75+
76+
Once created, you will be returned to the service accounts list.
77+
Find your newest entry matching the name you entered, and copy the "Client ID" column.
78+
79+
### 3) Deploying the chart:
80+
81+
Now we have the service account, let us prepare a namespace with the relevant private key needed at runtime.
82+
83+
```shell
84+
export VENAFI_CLIENT_ID="<PASTE YOURS HERE>"
85+
kubectl create namespace ${VENAFI_NAMESPACE}
86+
kubectl create secret generic agent-credentials -n ${VENAFI_NAMESPACE} \
87+
--from-file=privatekey.pem=${VENAFI_SERVICE_ACCOUNT}.pem
88+
```
89+
90+
Install the chart by setting the `config.clientId` field:
91+
92+
```shell
93+
helm upgrade --install venafi-kubernetes-agent deploy/charts/venafi-kubernetes-agent \
94+
--namespace ${VENAFI_NAMESPACE} \
95+
--set config.clientId="${VENAFI_CLIENT_ID}"
96+
```
97+
98+
Optionally if you need to change the backend to the EU Venafi Control Plane you can use:
99+
100+
```shell
101+
export VENAFI_SERVER_URL="https://api.venafi.eu/"
102+
helm upgrade --install venafi-kubernetes-agent deploy/charts/venafi-kubernetes-agent \
103+
--namespace ${VENAFI_NAMESPACE} \
104+
--set config.clientId="${VENAFI_CLIENT_ID}" \
105+
--set config.server="${VENAFI_SERVER_URL}"
106+
```
107+
108+
### 4) Add Cluster in Venafi Control Plane
109+
110+
- Go to "Installations" -> "Kubernetes Clusters" [here](https://ui.venafi.cloud/clusters-inventory) and click "Connect". **Note** you may need to click [here](https://ui.venafi.eu/clusters-inventory) for the EU backend.
111+
- On step 1 select "Continue".
112+
- On step 2 select "Advanced Connection".
113+
- On step 3 select "Continue" to skip.
114+
- On step 4, fill in the details as needed:
115+
- "Name" should match your service account name from before, e.g. "example-cluster".
116+
- Under "Service Account" click that drop down and select the previously created service account.
117+
- Then check the "The connection command has completed." box and select "continue".
118+
- On step 5, either wait for validation or select "Finish" to go back to the cluster list.
119+
120+
### 5) Deployment Verification
121+
122+
Check the agent logs to ensure you see a similar entry to the following:
123+
124+
```console
125+
2023/10/24 12:10:03 Running Agent...
126+
2023/10/24 12:10:03 Posting data to: https://api.venafi.cloud/
127+
2023/10/24 12:10:04 Data sent successfully.
128+
```
129+
130+
You can do this with the following command:
131+
132+
```shell
133+
kubectl logs -n ${VENAFI_NAMESPACE} $(kubectl get pod -n ${VENAFI_NAMESPACE} -l app.kubernetes.io/instance={{ .Release.Name }} -o jsonpath='{.items[0].metadata.name}')
134+
```
135+
136+
You can also check in the Venafi Control Plane to see when the "Last Check In" was for your cluster.
137+
138+
{{ template "chart.requirementsSection" . }}
139+
140+
{{ template "chart.valuesSection" . }}
141+
142+
{{ template "helm-docs.versionFooter" . }}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
1. Please make sure you have the credentials secret: "{{ .Values.authentication.secretName }}" available
2+
> kubectl get secret -n {{ .Release.Namespace }} {{ .Values.authentication.secretName }}
3+
4+
2. Check the application is running with the following:
5+
> kubectl get pods -n {{ .Release.Namespace }} -l app.kubernetes.io/instance={{ .Release.Name }}
6+
7+
3. Check the application logs for successful connection to the platform:
8+
> kubectl logs -n {{ .Release.Namespace }} $(kubectl get pod -n {{ .Release.Namespace }} -l app.kubernetes.io/instance={{ .Release.Name }} -o jsonpath='{.items[0].metadata.name}')

0 commit comments

Comments
 (0)