此内容没有您所选择的语言版本。
Chapter 1. Configuring secure communication with Redis
Using the Transport Layer Security (TLS) encryption with Red Hat OpenShift GitOps, you can secure the communication between the Argo CD components and Redis cache and protect the possibly sensitive data in transit.
You can secure communication with Redis by using one of the following configurations:
- 
					Enable the autotlssetting to issue an appropriate 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 the High Availability (HA) enabled.
1.1. Prerequisites
- 
						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
				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 - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- The name of the Argo CD instance.
- 2
- The namespace where you want to run the Argo CD instance.
- 3
- The flag that enables theautotlssetting and creates a TLS certificate for Redis.
- 4
- 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 asfalse.
 Tip- Alternatively, 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"}}}'- $ oc patch argocds.argoproj.io <instance-name> --type=merge -p '{"spec":{"redis":{"autotls":"openshift"}}}'- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Click Create.
- Verify that the Argo CD pods are ready and running: - oc get pods -n <namespace> - $ oc get pods -n <namespace>- 1 - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- Specify a namespace where the Argo CD instance is running, for exampleopenshift-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 37s - 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 37s- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow Note- The 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 - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 
- 
								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> - $ oc get secrets argocd-operator-redis-tls -n <namespace>- 1 - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- Specify a namespace where the Argo CD instance is running, for exampleopenshift-gitops.
 - Example output - NAME TYPE DATA AGE argocd-operator-redis-tls kubernetes.io/tls 2 30s - NAME TYPE DATA AGE argocd-operator-redis-tls kubernetes.io/tls 2 30s- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - The secret must be of the - kubernetes.io/tlstype and a size of- 2.
1.3. Configuring TLS for Redis with autotls disabled
				You can manually configure TLS encryption for Redis by creating the argocd-operator-redis-tls secret with a key and certificate pair. In addition, you must annotate the secret to indicate that it belongs to the appropriate Argo CD instance. The steps to create a certificate and secret vary for instances with High Availability (HA) enabled.
			
Procedure
- Log in to the OpenShift Container Platform web console.
- Create an Argo CD instance: - 
								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 ArgoCD CR with autotls disabled - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Click Create.
- Verify that the Argo CD pods are ready and running: - oc get pods -n <namespace> - $ oc get pods -n <namespace>- 1 - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- Specify a namespace where the Argo CD instance is running, for exampleopenshift-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 37s - 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 37s- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow Note- The 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 - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 
- 
								In the Administrator perspective of the web console, use the left navigation panel to go to Administration 
- Create a self-signed certificate for the Redis server by using one of the following options depending on your HA configuration: - For the Argo CD instance with HA disabled, run the following command: - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- Specify a namespace where the Argo CD instance is running, for exampleopenshift-gitops.
 - Example output - Generating a RSA private key ...............++++ ............................++++ writing new private key to '/tmp/redis.key' - Generating a RSA private key ...............++++ ............................++++ writing new private key to '/tmp/redis.key'- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- For the Argo CD instance with HA enabled, run the following command: - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- Specify a namespace where the Argo CD instance is running, for exampleopenshift-gitops.
 - Example output - Generating a RSA private key ...............++++ ............................++++ writing new private key to '/tmp/redis-ha.key' - Generating a RSA private key ...............++++ ............................++++ writing new private key to '/tmp/redis-ha.key'- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 
- Verify that the generated certificate and key are available in the - /tmpdirectory by running the following commands:- cd /tmp - $ cd /tmp- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - ls - $ ls- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output with HA disabled - ... redis.crt redis.key ... - ... redis.crt redis.key ...- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output with HA enabled - ... redis-ha.crt redis-ha.key ... - ... redis-ha.crt redis-ha.key ...- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Create the - argocd-operator-redis-tlssecret by using one of the following options depending on your HA configuration:- For the Argo CD instance with HA disabled, run the following command: - oc create secret tls argocd-operator-redis-tls --key=/tmp/redis.key --cert=/tmp/redis.crt - $ oc create secret tls argocd-operator-redis-tls --key=/tmp/redis.key --cert=/tmp/redis.crt- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- For the Argo CD instance with HA enabled, run the following command: - oc create secret tls argocd-operator-redis-tls --key=/tmp/redis-ha.key --cert=/tmp/redis-ha.crt - $ oc create secret tls argocd-operator-redis-tls --key=/tmp/redis-ha.key --cert=/tmp/redis-ha.crt- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - secret/argocd-operator-redis-tls created - secret/argocd-operator-redis-tls created- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 
- 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> - $ oc annotate secret argocd-operator-redis-tls argocds.argoproj.io/name=<instance-name>- 1 - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- Specify a name of the Argo CD instance, for exampleargocd.
 - Example output - secret/argocd-operator-redis-tls annotated - secret/argocd-operator-redis-tls annotated- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Verify that the Argo CD pods are ready and running: - oc get pods -n <namespace> - $ oc get pods -n <namespace>- 1 - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- Specify a namespace where the Argo CD instance is running, for exampleopenshift-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 37s - 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 37s- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow Note- 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 - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow