F5 NGINX Management Suite is a family of modules for managing the NGINX data plane from a single pane of glass. By simplifying management of NGINX Open Source and NGINX Plus instances, NGINX Management Suite simplifies your processes for scaling, securing, and monitoring applications and APIs.
Vous devez installer l'agent NGINX sur chaque instance NGINX que vous souhaitez gérer à partir de NGINX Management Suite, pour activer la communication avec le plan de contrôle et la gestion de la configuration à distance.
Pour les instances NGINX exécutées sur du bare metal ou une machine virtuelle (VM), nous fournissons des instructions d'installation dans notre documentation. Dans cet article, nous montrons comment créer une image Docker pour NGINX Plus et NGINX Agent, afin d'élargir la portée de NGINX Management Suite aux instances NGINX Plus déployées dans Kubernetes ou d'autres infrastructures de microservices.
Il existe trois options de construction, en fonction de ce que vous souhaitez inclure dans l'image Docker résultante :
[ Éditeur – Cet article a été mis à jour en avril 2023 pour clarifier les instructions et ajouter le champ ACM_DEVPORTAL
à l’étape 1 de l’exécution de l’image Docker dans Kubernetes .]
We provide a GitHub repository of the resources you need to create a Docker image of NGINX Plus and NGINX Agent, with support for version 2.8.0 and later of the Instance Manager module from NGINX Management Suite.
To build the Docker image, you need:
Pour exécuter l’image Docker, vous avez besoin de :
kubectl
avec accès au cluster KubernetesFollow these instructions to build the Docker image.
Cloner le dépôt GitHub :
$ git clone https://github.com/nginxinc/NGINX-Demos Clonage dans 'NGINX-Demos'... à distance : Énumération des objets : 126, terminé. à distance : Compter les objets : 100% (126/126), terminé. à distance : Compression d'objets : 100% (85/85), terminé. à distance : Total 126 (delta 61), réutilisé 102 (delta 37), pack-réutilisé 0 Objets de réception : 100 % (126/126), 20,44 Ko | 1,02 Mio/s, terminé.
Résolution des deltas : 100% (61/61), fait.
Change to the build directory:
$ cd NGINX-Demos/nginx-agent-docker/
Run docker
ps
to verify that Docker is running and then run the build.sh script to include the desired software in the Docker image. The base options are:
‑C
– Name of the NGINX Plus license certificate file (nginx-repo.crt
in the sample commands below)‑K
– Nom du fichier de clé de licence NGINX Plus ( nginx-repo.key
dans les exemples de commandes ci-dessous)‑t
– Le registre et l’image cible sous la forme
<nom_registre>/<nom_image>:<étiquette>
(registry.ff.lan:31005/nginx-plus-with-agent:2.7.0
in the sample commands below)
‑n
– URL de base de votre instance NGINX Management Suite ( https://nim.f5.ff.lan
dans les exemples de commandes ci-dessous)The additional options are:
‑d
– Add data‑plane support for the developer portal when using NGINX API Connectivity Manager‑w
– Ajouter NGINX App Protect WAFHere are the commands for the different combinations of software:
NGINX Plus and NGINX Agent:
$ ./scripts/build.sh -C nginx-repo.crt -K nginx-repo.key \
-t registry.ff.lan:31005/nginx-plus-with-agent:2.7.0 \
-n https://nim.f5.ff.lan
NGINX Plus, NGINX Agent, and NGINX App Protect WAF (add the ‑w
option):
$ ./scripts/build.sh -C nginx-repo.crt -K nginx-repo.key \-t registry.ff.lan:31005/nginx-plus-with-agent:2.7.0 -w \ -n https://nim.f5.ff.lan
NGINX Plus, NGINX Agent, and developer portal support (add the ‑d
option):
$ ./scripts/build.sh -C nginx-repo.crt -K nginx-repo.key \ -t registry.ff.lan:31005/nginx-plus-with-agent:2.7.0 -d \ -n https://nim.f5.ff.lan
Voici un exemple de trace de la construction d'une image de base. Le message « Build
terminé »
à la fin indique une build réussie.
$ ./scripts/build.sh -C nginx-repo.crt -K nginx-repo.key -t registry.ff.lan:31005/nginx-plus-with-agent:2.7.0 -n https://nim.f5.ff.lan => L'image Docker cible est nginx-plus-with-agent:2.7.0 [+] Construction de 415.1s (10/10) TERMINÉE => [interne] charger la définition de construction à partir du Dockerfile => transfert du dockerfile : 38B => [interne] load .dockerignore => transfert de contexte : 2B => [interne] charger les métadonnées pour docker.io/library/centos:7 => [auth] library/centos:pull token for registry-1.docker.io => CACHED [1/4] FROM docker.io/library /centos:7@sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4 => [interne] charger le contexte de construction => transférer le contexte : 69B => [2/4] EXÉCUTER yum -y update && yum install -y wget ca-certificates epel-release curl && mkdir -p /deployment /etc/ssl/nginx && bash -c 'curl -k $NMS_URL/install/nginx-agent | sh' && echo "A 299.1s => [3/4] COPY ./container/start.sh /deployment/ => [4/4] RUN --mount=type=secret,id=nginx-crt,dst=/etc/ssl/nginx/nginx-repo.crt --mount=type=secret,id=nginx-key,dst=/etc/ssl/nginx/nginx-repo.key set -x && chmod +x /deployment/start.sh & 102.4s => exportation vers image => exportation des calques => écriture de l'image sha256:9246de4af659596a290b078e6443a19b8988ca77f36ab90af3b67c03d27068ff => dénomination vers Registry.ff.lan:31005/nginx-plus-with-agent:2.7.0 => Construction terminée pour Registry.ff.lan:31005/nginx-plus-with-agent:2.7.0
Suivez ces instructions pour préparer le manifeste de déploiement et démarrer NGINX Plus avec NGINX Agent sur Kubernetes.
Using your preferred text editor, open manifests/1.nginx-with-agent.yaml and make the following changes (the code snippets show the default values that you can or must change, highlighted in orange):
In the spec.template.spec.containers
section, replace the default image name (your.registry.tld/nginx-with-nim2-agent:tag
) with the Docker image name you specified with the ‑t
option in Step 3 of Building the Docker Image (in our case, registry.ff.lan:31005/nginx-plus-with-agent:2.7.0):
spec: ... template: ... spec: conteneurs: - nom: nginx-nim image: your.registry.tld/nginx-with-nim2-agent:tag
Dans la section spec.template.spec.containers.env
, effectuez ces substitutions dans le champ de valeur
pour chaque nom
indiqué :
NIM_HOST
– (Required) Replace the default (nginx-nim2.nginx-nim2
) with the FQDN or IP address of your NGINX Management Suite instance (in our case nim2.f5.ff.lan).NIM_GRPC_PORT
– (Facultatif) Remplacez la valeur par défaut (443
) avec un numéro de port différent pour le trafic gRPC.NIM_INSTANCEGROUP
– (Facultatif) Remplacez la valeur par défaut ( lab
) par le groupe d’instances auquel appartient l’instance NGINX Plus.NIM_TAGS
– (Facultatif) Remplacez la valeur par défaut ( preprod,devops
) par une liste de balises délimitées par des virgules pour l’instance NGINX Plus.spec:
...
template:
...
spec:
containers:
...
env:
- name: NIM_HOST
...
value: "nginx-nim2.nginx-nim2"
- name: NIM_GRPC_PORT
value: "443"
- name: NIM_INSTANCEGROUP
value: "lab"
- name: NIM_TAGS
value: "preprod,devops"
Également dans la section spec.template.spec.containers.env
, supprimez le commentaire de ces paires de champs nom
- valeur
si la condition indiquée s'applique :
NIM_WAF
et NIM_WAF_PRECOMPILED_POLICIES
– NGINX App Protect WAF est inclus dans l'image (vous avez inclus l'option -w
à l'étape 3 de la création de l'image Docker ), donc la valeur est « true »
.ACM_DEVPORTAL
– Support for the App Connectivity Manager developer portal is included in the image (you included the -d
option in Step 3 of Building the Docker Image), so the value is "true"
.spec: ... template: ... spec: conteneurs: ... env: - nom: NIM_HOST ... #- nom : NAP_WAF # valeur : « true » #- nom : NAP_WAF_PRECOMPILED_POLICIES # valeur : « true » ... #- nom : ACM_DEVPORTAL # valeur : « true »
Exécutez le script nginxwithAgentStart.sh comme indiqué pour appliquer le manifeste et démarrer deux pods (comme spécifié par les répliques :
2
instructions dans la section spec
du manifeste), chacun avec NGINX Plus et NGINX Agent :
$ ./scripts/nginxWithAgentStart.sh démarrer $ ./scripts/nginxWithAgentStart.sh arrêter
Verify that two pods are now running: each pod runs an NGINX Plus instance and an NGINX Agent to communicate with the NGINX Management Suite control plane.
$ kubectl get pods -n nim-test NOM PRÊT ÉTAT RESTARTS AGE nginx-nim-7f77c8bdc9-hkkck 1/1 En cours d'exécution 0 1m nginx-nim-7f77c8bdc9-p2s94 1/1 En cours d'exécution 0 1m
Accédez à l'interface graphique du gestionnaire d'instances NGINX dans NGINX Management Suite et vérifiez que deux instances NGINX Plus sont en cours d'exécution avec le statut En ligne . Dans cet exemple, NGINX App Protect WAF n'est pas activé.
To try out the NGINX solutions discussed in this post, start a 30-day free trial today or contact us to discuss your use cases:
Téléchargez NGINX Agent – c'est gratuit et open source.
"This blog post may reference products that are no longer available and/or no longer supported. For the most current information about available F5 NGINX products and solutions, explore our NGINX product family. NGINX is now part of F5. All previous NGINX.com links will redirect to similar NGINX content on F5.com."