Skip to content

Commit deefff1

Browse files
Update JWT install guide (#3884) (#4263)
(cherry picked from commit 1cc4428)
1 parent 64045c8 commit deefff1

File tree

1 file changed

+144
-22
lines changed

1 file changed

+144
-22
lines changed
Lines changed: 144 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,157 @@
11
---
2-
title: Using the NGINX IC Plus JWT token in a Docker Config Secret
3-
description: "This document explains how to use the NGINX Plus Ingress Controller image from the F5 Docker registry in your Kubernetes cluster by using your NGINX Ingress Controller subscription JWT token."
2+
title: Using NGINX Ingress Controller Plus JWT token in a Docker Config Secret
3+
description: "This document explains how to use the NGINX Plus Ingress Controller image from the F5 Docker registry in your Kubernetes cluster by using an NGINX Ingress Controller subscription JWT token."
44
weight: 1600
55
doctypes: [""]
66
toc: true
7-
docs: "DOCS-608"
87
---
98

10-
This document explains how to use the NGINX Plus Ingress Controller image from the F5 Docker registry in your Kubernetes cluster by using your NGINX Ingress Controller subscription JWT token. **Please note that an NGINX Plus subscription certificate and key will not work with the F5 Docker registry.** You can also get the image using alternative methods:
9+
## Overview
1110

12-
* You can use Docker to pull an Ingress Controller image with NGINX Plus and push it to your private registry by following the [Pulling the Ingress Controller Image]({{< relref "/installation/pulling-ingress-controller-image.md" >}}) documentation.
13-
* Please see the [information on how to build an Ingress Controller image]({{< relref "/installation/building-ingress-controller-image.md" >}}) using the source code from this repository and your NGINX Plus subscription certificate and key.
14-
* Note that for NGINX Ingress Controller based on NGINX OSS, we provide the image through [DockerHub](https://hub.docker.com/r/nginx/nginx-ingress/).
11+
This document explains how to pull the NGINX Plus Ingress Controller image from the F5 Docker registry into your Kubernetes cluster using your JWT token.
1512

16-
## Prerequisites
13+
{{<note>}}
14+
An NGINX Plus subscription certificate and key will not work with the F5 Docker registry.
15+
For NGINX Ingress Controller, you must have the NGINX Ingress Controller subscription -- download the NGINX Plus Ingress Controller (per instance) JWT access token from [MyF5](https://my.f5.com).
16+
To list the available image tags using the Docker registry API, you will also need to download the NGINX Plus Ingress Controller (per instance) certificate (`nginx-repo.crt`) and the key (`nginx-repo.key`) from [MyF5](https://my.f5.com).
17+
{{</note>}}
1718

18-
* For NGINX Ingress Controller, you must have the NGINX Ingress Controller subscription -- download the NGINX Plus Ingress Controller (per instance) JWT access token from [MyF5](https://my.f5.com).
19-
* To list the available image tags using the Docker registry API, you will also need to download the NGINX Plus Ingress Controller (per instance) certificate (`nginx-repo.crt`) and the key (`nginx-repo.key`) from [MyF5](https://my.f5.com).
19+
You can also get the image using alternative methods:
20+
21+
* You can use Docker to pull an NGINX Ingress Controller image with NGINX Plus and push it to your private registry by following the ["Pulling the Ingress Controller Image"](https://docs.nginx.com/nginx-ingress-controller/installation/pulling-ingress-controller-image/) documentation.
22+
* You can also build an NGINX Ingress Controller image by following the ["Information on how to build an Ingress Controller image"](https://docs.nginx.com/nginx-ingress-controller/installation/building-ingress-controller-image/) documentation.
23+
24+
If you would like an NGINX Ingress Controller image using NGINX open source, we provide the image through [DockerHub](https://hub.docker.com/r/nginx/nginx-ingress/).
25+
26+
## Before You Begin
27+
28+
You will need the following information from [MyF5](https://my.f5.com) for these steps:
29+
30+
* A JWT Access Token (Per instance) for NGINX Ingress Controller from an active NGINX Ingress Controller subscription.
31+
* The certificate (`nginx-repo.crt`) and key (`nginx-repo.key`) for each NGINX Ingress Controller instance, used to list the available image tags from the Docker registry API.
32+
33+
## Prepare NGINX Ingress Controller
34+
35+
1. Choose your desired [NGINX Ingress Controller Image](https://docs.nginx.com/nginx-ingress-controller/technical-specifications/#images-with-nginx-plus).
36+
1. Log into the [MyF5 Portal](https://myf5.com/), navigate to your subscription details, and download the relevant .cert, .key and .JWT files.
37+
1. Create a Kubernetes secret using the JWT token. You should use `cat` to view the contents of the JWT token and store the output for use in later steps.
38+
1. Ensure there are no additional characters or extra whiespace that might have been accidently added. This will break authorization and prevent the NGINX Ingress Controller image from being downloaded.
39+
1. Modify your deployment (manifest or helm) to use the Kubernetes secret created in step three.
40+
1. Deploy NGINX Ingress Controller into your Kubernetes cluster and verify successful installation.
2041

2142
## Using the JWT token in a Docker Config Secret
2243

23-
1. Create a `docker-registry` secret on the cluster using the JWT token as the username and `none` for password (password is unused). The name of the docker server is `private-registry.nginx.com`. Optionally namespace the secret.
44+
1. Create a kubernetes `docker-registry` secret type on the cluster, using the JWT token as the username and `none` for password (Password is unused). The name of the docker server is `private-registry.nginx.com`.
45+
46+
47+
```shell
48+
kubectl create secret docker-registry regcred --docker-server=private-registry.nginx.com --docker-username=<JWT Token> --docker-password=none [-n nginx-ingress]
49+
```
50+
It is important that the `--docker-username=<JWT Token>` contains the contents of the token and is not pointing to the token itself. Ensure that when you copy the contents of the JWT token, there are no additional characters or extra whitepaces. This can invalidate the token and cause 401 errors when trying to authenticate to the registry.
51+
52+
53+
1. Confirm the details of the created secret by running:
2454

25-
```console
26-
kubectl create secret docker-registry regcred --docker-server=private-registry.nginx.com --docker-username=<JWT Token> --docker-password=none [-n nginx-ingress]
55+
```shell
56+
kubectl get secret regcred --output=yaml
57+
```
58+
59+
60+
1. You can now use the newly created Kubernetes secret in `helm` and `manifest` deployments.
61+
62+
## Manifest Deployment
63+
64+
The page ["Installation with Manifests"](https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-manifests/) explains how to install NGINX Ingress Controller using manifests. The following snippet is an example of a deployment:
65+
66+
```yaml
67+
spec:
68+
serviceAccountName: nginx-ingress
69+
imagePullSecrets:
70+
- name: regcred
71+
automountServiceAccountToken: true
72+
securityContext:
73+
seccompProfile:
74+
type: RuntimeDefault
75+
containers:
76+
- image: private-registry.nginx.com/nginx-ic/nginx-plus-ingress:3.2.0
77+
imagePullPolicy: IfNotPresent
78+
name: nginx-plus-ingress
2779
```
2880
29-
2. Confirm the details of the created secret by running:
81+
The `imagePullSecrets` and `containers.image` lines represent the Kubernetes secret, as well as the registry and version of the NGINX Ingress Controller we are going to deploy.
82+
83+
## Helm Deployment
84+
85+
If you are using `helm` for deployment, there are two main methods: using *sources* or *charts*.
86+
87+
### Helm Source
88+
89+
The [Helm installation page for NGINX Ingess Controller](https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-helm/#managing-the-chart-via-sources) has a section describing how to use sources: these are the unique steps for Docker secrets using JWT tokens.
90+
91+
1. Clone the NGINX [`kubernetes-ingress` repository](https://github.com/nginxinc/kubernetes-ingress).
92+
1. Navigate to the `deployments/helm-chart` folder of your local clone.
93+
1. Open the `values.yaml` file in an editor.
94+
95+
You must change a few lines NGINX Ingress Controller with NGINX Plus to be deployed.
3096

31-
```console
32-
kubectl get secret regcred --output=yaml
97+
1. Change the `nginxplus` argument to `true`.
98+
1. Change the `repository` argument to the NGINX Ingress Controller image you intend to use.
99+
1. Add an argument to `imagePullSecretName` to allow Docker to pull the image from the private registry.
100+
101+
The following codeblock shows snippets of the parameters you will need to change, and an example of their contents:
102+
103+
```yaml
104+
## Deploys the Ingress Controller for NGINX Plus
105+
nginxplus: true
106+
## Truncated fields
107+
## ...
108+
## ...
109+
image:
110+
## The image repository for the desired NGINX Ingress Controller image
111+
repository: private-registry.nginx.com/nginx-ic/nginx-plus-ingress
112+
113+
## The version tag
114+
tag: 3.2.0
115+
116+
serviceAccount:
117+
## The annotations of the service account of the Ingress Controller pods.
118+
annotations: {}
119+
120+
## Truncated fields
121+
## ...
122+
## ...
123+
124+
## The name of the secret containing docker registry credentials.
125+
## Secret must exist in the same namespace as the helm release.
126+
imagePullSecretName: regcred
33127
```
34128

35-
3. You can now add this secret to a deployment spec or to a service account to apply to all deployments for a given SA spec. See the [Create a Pod that uses your Secret](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-pod-that-uses-your-secret) and [Add ImagePullSecrets to a service account](https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#add-imagepullsecrets-to-a-service-account) documentation for more details.
129+
With `values.yaml` modified, you can now use Helm to install NGINX Ingress Controller, such as in the following example:
36130

37-
4. Update the deployment spec with the chosen image path. Choose the image from the [available images]({{< relref "/technical-specifications.md#images-with-nginx-plus" >}}).
131+
```shell
132+
helm install nicdev01 -n nginx-ingress --create-namespace -f values.yaml .
133+
```
134+
135+
The above command will install NGINX Ingress Controller in the `nginx-ingress` namespace.
136+
137+
If the namespace does not exist, `--create-namespace` will create it. Using `-f values.yaml` tells `helm` to use the `values.yaml` file that you modified earlier with the settings you want to apply for your NGINX Ingress Controller deployment.
38138

39-
5. You can use the certificate and key from the MyF5 portal and the Docker registry API to list the available image tags for the repositories, e.g.:
40139

41-
```json
140+
### Helm Chart
141+
142+
If you want to install NGINX Ingress Controller using the charts method, the following is an example of using the command line to pass the required arguments using the `set` parameter.
143+
144+
```shell
145+
helm install my-release -n nginx-ingress oci://ghcr.io/nginxinc/charts/nginx-ingress --version 0.18.0 --set controller.image.repository=private-registry.nginx.com/nginx-ic/nginx-plus-ingress --set controller.image.tag=3.2.0 --set controller.nginxplus=true --set controller.serviceAccount.imagePullSecretName=regcred
146+
```
147+
148+
Checking the validation that the .crts/key and .jwt are able to successfully authenticate to the repo to pull NGINX Ingress controller images:
149+
150+
You can also use the certificate and key from the MyF5 portal and the Docker registry API to list the available image tags for the repositories, e.g.:
151+
152+
```shell
153+
$ curl https://private-registry.nginx.com/v2/nginx-ic/nginx-plus-ingress/tags/list --key <path-to-client.key> --cert <path-to-client.cert> | jq
42154
43-
$ curl <https://private-registry.nginx.com/v2/nginx-ic/nginx-plus-ingress/tags/list> --key <path-to-client.key> --cert <path-to-client.cert> | jq
44155
{
45156
"name": "nginx-ic/nginx-plus-ingress",
46157
"tags": [
@@ -67,4 +178,15 @@ kubectl get secret regcred --output=yaml
67178
"3.2.0"
68179
]
69180
}
70-
```
181+
```
182+
183+
## Pulling an Image for Local Use
184+
185+
If you need to pull the image for local use to then push to a different container registry, here is the command:
186+
187+
```shell
188+
docker login private-registry.nginx.com --username=<output_of_jwt_token> --password=none
189+
```
190+
191+
Replace the contents of `<output_of_jwt_token>` with the contents of the `jwt token` itself.
192+
Once you have successfully pulled the image, you can then tag it as needed.

0 commit comments

Comments
 (0)