Este conteúdo não está disponível no idioma selecionado.
Chapter 1. Configuring secure communication with Redis
You can use Transport Layer Security (TLS) encryption with Red Hat OpenShift GitOps to secure communication between Argo CD components and the Redis cache, protecting sensitive data in transit.
You can secure communication with Redis by using one of the following configurations:
-
Enable the
autotlssetting to automatically generate and configure a certificate for TLS encryption. -
Manually configure the TLS encryption by creating the
argocd-operator-redis-tlssecret with a key and certificate pair.
Both configurations are possible with or without High Availability (HA).
1.1. Prerequisites Copiar o linkLink copiado para a área de transferência!
-
You have access to the cluster with
cluster-adminprivileges. - You have access to the OpenShift Container Platform web console.
- Red Hat OpenShift GitOps Operator is installed on your cluster.
1.2. Configuring TLS for Redis with autotls enabled Copiar o linkLink copiado para a área de transferência!
You can configure TLS encryption for Redis by enabling the autotls setting on a new or already existing Argo CD instance. The configuration automatically provisions the argocd-operator-redis-tls secret and does not require further steps. Currently, OpenShift Container Platform is the only supported secret provider.
By default, the autotls setting is disabled.
Procedure
- Log in to the OpenShift Container Platform web console.
Create an Argo CD instance with
autotlsenabled:-
In the Administrator perspective of the web console, use the left navigation panel to go to Administration
CustomResourceDefinitions. -
Search for
argocds.argoproj.ioand clickArgoCDcustom resource definition (CRD). - On the CustomResourceDefinition details page, click the Instances tab, and then click Create ArgoCD.
Edit or replace the YAML similar to the following example:
Example Argo CD CR with autotls enabled:
apiVersion: argoproj.io/v1beta1 kind: ArgoCD metadata: name: argocd namespace: openshift-gitops spec: redis: autotls: openshift ha: enabled: truewhere:
metadata.name- Specifies the name of the Argo CD instance.
metadata.namespace- Specifies the namespace where the Argo CD instance runs.
spec.redis.autotls-
Enables automatic TLS certificate generation for Redis. Set to
openshiftto use the OpenShift service CA. spec.ha.enabled-
Enables the HA feature. Omit this field or set it to
falseto disable HA.
TipAlternatively, you can enable the
autotlssetting on an already existing Argo CD instance by running the following command:$ oc patch argocds.argoproj.io <instance-name> \ --type=merge \ -p '{"spec":{"redis":{"autotls":"openshift"}}}' \ -n <namespace>- Click Create.
Verify that the Argo CD pods are ready and running:
$ oc get pods -n <namespace>where:
<namespace>-
Specifies a namespace where the Argo CD instance is running, for example
openshift-gitops.
Example output with HA disabled:
NAME READY STATUS RESTARTS AGE argocd-application-controller-0 1/1 Running 0 26s argocd-redis-84b77d4f58-vp6zm 1/1 Running 0 37s argocd-repo-server-5b959b57f4-znxjq 1/1 Running 0 37s argocd-server-6b8787d686-wv9zh 1/1 Running 0 37sNoteThe HA-enabled TLS configuration requires a cluster with at least three worker nodes. It can take a few minutes for the output to appear if you have enabled the Argo CD instances with HA configuration.
Example output with HA enabled:
NAME READY STATUS RESTARTS AGE argocd-application-controller-0 1/1 Running 0 10m argocd-redis-ha-haproxy-669757fdb7-5xg8h 1/1 Running 0 10m argocd-redis-ha-server-0 2/2 Running 0 9m9s argocd-redis-ha-server-1 2/2 Running 0 98s argocd-redis-ha-server-2 2/2 Running 0 53s argocd-repo-server-576499d46d-8hgbh 1/1 Running 0 10m argocd-server-9486f88b7-dk2ks 1/1 Running 0 10m
-
In the Administrator perspective of the web console, use the left navigation panel to go to Administration
Verify that the
argocd-operator-redis-tlssecret is created:$ oc get secrets argocd-operator-redis-tls -n <namespace>where:
<namespace>Specifies the namespace where the Argo CD instance is running, for example
openshift-gitops.Example output:
NAME TYPE DATA AGE argocd-operator-redis-tls kubernetes.io/tls 2 30sThe secret must be of type
kubernetes.io/tlsand contain 2 data fields (certificate and key).
1.3. Configuring TLS for Redis with autotls disabled Copiar o linkLink copiado para a área de transferência!
You can manually configure TLS encryption for Redis by creating the argocd-operator-redis-tls secret with a key and certificate pair and annotating the secret to associate it with the appropriate Argo CD instance.
Procedure
- Log in to the OpenShift Container Platform web console.
Create an Argo CD instance:
-
In the Administrator perspective of the web console, go to Administration
CustomResourceDefinitions. -
Search for
argocds.argoproj.ioand clickArgoCD. - On the CustomResourceDefinition details page, click the Instances tab, and then click Create ArgoCD.
Edit or replace the YAML similar to the following example:
apiVersion: argoproj.io/v1beta1 kind: ArgoCD metadata: name: argocd namespace: openshift-gitops spec: ha: enabled: truewhere:
metadata.name- Specifies the name of the Argo CD instance.
metadata.namespace- Specifies the namespace where you want to run the Argo CD instance.
spec.ha.enabled-
Specifies the flag value that enables the HA feature. If you do not want to enable HA, do not include this line or set the flag value as
false.
- Click Create.
Verify that the Argo CD pods are ready and running:
$ oc get pods -n <namespace>where:
<namespace>Specifies a namespace where the Argo CD instance is running, for example
openshift-gitops.Example output with HA disabled:
NAME READY STATUS RESTARTS AGE argocd-application-controller-0 1/1 Running 0 26s argocd-redis-84b77d4f58-vp6zm 1/1 Running 0 37s argocd-repo-server-5b959b57f4-znxjq 1/1 Running 0 37s argocd-server-6b8787d686-wv9zh 1/1 Running 0 37sNoteThe HA-enabled TLS configuration requires a cluster with at least three worker nodes. It can take a few minutes for the output to appear if you have enabled the Argo CD instances with HA configuration.
Example output with HA enabled:
NAME READY STATUS RESTARTS AGE argocd-application-controller-0 1/1 Running 0 10m argocd-redis-ha-haproxy-669757fdb7-5xg8h 1/1 Running 0 10m argocd-redis-ha-server-0 2/2 Running 0 9m9s argocd-redis-ha-server-1 2/2 Running 0 98s argocd-redis-ha-server-2 2/2 Running 0 53s argocd-repo-server-576499d46d-8hgbh 1/1 Running 0 10m argocd-server-9486f88b7-dk2ks 1/1 Running 0 10m
-
In the Administrator perspective of the web console, go to Administration
Create a self-signed certificate for the Redis server:
For the Argo CD instance with HA disabled:
$ openssl req -new -x509 -sha256 \ -subj "/C=XX/ST=XX/O=Testing/CN=redis" \ -reqexts SAN -extensions SAN \ -config <(printf "\n[SAN]\nsubjectAltName=DNS:argocd-redis.<namespace>.svc.cluster.local\n[req]\ndistinguished_name=req") \ -keyout /tmp/redis.key \ -out /tmp/redis.crt \ -newkey rsa:4096 \ -nodes \ -days 10where:
<namespace>Specifies a namespace where the Argo CD instance is running, for example
openshift-gitops.Example output:
Generating a RSA private key ...............++++ ............................++++ writing new private key to '/tmp/redis.key'
For the Argo CD instance with HA enabled:
$ openssl req -new -x509 -sha256 \ -subj "/C=XX/ST=XX/O=Testing/CN=redis" \ -reqexts SAN -extensions SAN \ -config <(printf "\n[SAN]\nsubjectAltName=DNS:argocd-redis-ha-haproxy.<namespace>.svc.cluster.local\n[req]\ndistinguished_name=req") \ -keyout /tmp/redis-ha.key \ -out /tmp/redis-ha.crt \ -newkey rsa:4096 \ -nodes \ -days 10where:
<namespace>Specifies a namespace where the Argo CD instance is running, for example
openshift-gitops.Example output:
Generating a RSA private key ...............++++ ............................++++ writing new private key to '/tmp/redis-ha.key'
Verify that the generated files are available:
$ cd /tmp $ lsExample output with HA disabled:
... redis.crt redis.key ...Example output with HA enabled:
... redis-ha.crt redis-ha.key ...Create the
argocd-operator-redis-tlssecret:For the Argo CD instance with HA disabled:
$ oc create secret tls argocd-operator-redis-tls \ --key=/tmp/redis.key \ --cert=/tmp/redis.crt \ -n <namespace>where:
<namespace>-
Specifies the namespace where the Argo CD instance is running, for example
openshift-gitops.
For the Argo CD instance with HA enabled:
$ oc create secret tls argocd-operator-redis-tls \ --key=/tmp/redis-ha.key \ --cert=/tmp/redis-ha.crt \ -n <namespace>where:
<namespace>Specifies the namespace where the Argo CD instance is running, for example
openshift-gitops.Example output:
secret/argocd-operator-redis-tls created
Annotate the secret to indicate that it belongs to the Argo CD CR:
$ oc annotate secret argocd-operator-redis-tls \ argocds.argoproj.io/name=<instance-name> \ -n <namespace>where:
<instance-name>-
Specifies a name of the Argo CD instance, for example
argocd. <namespace>Specifies the namespace where the Argo CD instance is running, for example
openshift-gitops.Example output:
secret/argocd-operator-redis-tls annotated
Verify that the Argo CD pods are ready and running:
$ oc get pods -n <namespace>where:
<namespace>Specifies a namespace where the Argo CD instance is running, for example
openshift-gitops.Example output with HA disabled:
NAME READY STATUS RESTARTS AGE argocd-application-controller-0 1/1 Running 0 26s argocd-redis-84b77d4f58-vp6zm 1/1 Running 0 37s argocd-repo-server-5b959b57f4-znxjq 1/1 Running 0 37s argocd-server-6b8787d686-wv9zh 1/1 Running 0 37sNoteIt can take a few minutes for the output to appear if you have enabled the Argo CD instances with HA configuration.
Example output with HA enabled:
NAME READY STATUS RESTARTS AGE argocd-application-controller-0 1/1 Running 0 10m argocd-redis-ha-haproxy-669757fdb7-5xg8h 1/1 Running 0 10m argocd-redis-ha-server-0 2/2 Running 0 9m9s argocd-redis-ha-server-1 2/2 Running 0 98s argocd-redis-ha-server-2 2/2 Running 0 53s argocd-repo-server-576499d46d-8hgbh 1/1 Running 0 10m argocd-server-9486f88b7-dk2ks 1/1 Running 0 10m