Installation and deployment

ArgoCD is very easy to deploy. Install the official deployment method (HA mode:

1
2
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/v1.5.2/manifests/ha/install.yaml

You can adjust the deployment file as needed. After the pod is successfully started

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# kubectl -n argocd get pod
NAME READY STATUS RESTARTS AGE
argocd-application-controller-66fbf66657-ghf2c 1/1 Running 0 6d17h
argocd-application-controller-66fbf66657-gpm7d 1/1 Running 0 6d17h argocd-application-controller-66fbf66657-tr5kd 1/1 Running 0 6d17h argocd-dex-server-5c5f986596-c8ftv 1/1 Running 0 9d argocd-redis-ha-haproxy-69c6df79c6-2fxd6 1/1 Running 0 9d argocd-redis-ha-haproxy-69c6df79c6-mksg2 1/1 Running 0 9d argocd-redis-ha-haproxy-69c6df79c6-wq57f 1/1 Running 0 9d argocd-redis-ha-server-0 2/2 Running 0 9d argocd-redis-ha-server-1 2/ 2 Running 0 9d argocd-redis-ha-server-2 2/2 Running 0 9d argocd-repo-server-76bbb56cc7-d8fp5 1/1 Running 0 7d argocd-repo-server-76bbb56cc7-qvl5z 1/1 Running 0 7d argocd-repo-server-76bbb56cc7-xq rfn 1/1 Running 0 7d argocd-server-6464c7bcd-fgktr 1/1 Running 0 6d19h argocd-server-6464c7bcd-jkqdb 1/1 Running 0 6d19h argocd-server-6464c7bcd-nfdwn 1/1 Running 0 6d19h ` `` ## Configure ingress to access argocd

```yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: argocd-server-ingress
namespace: argocd
annotations:
kubernetes.io/ingress.class: traefik
traefik.ingress.kubernetes.io/redirect-entry-point: https
spec:
rules:
- host: cd.testcn
http:
paths:
- backend:
serviceName: argocd-server
servicePort: https
path: /

Access argocd through https://cd.test.cn/. The default local username is admin and the password is the name of one of the pods. To get the password, use the following method:

1
# kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-server -o name | cut -d'/' -f 2

argocd

User management

argocd uses local users by default and supports ldap. Local user management uses the configmap method of modifying argocd-cm. Add new users as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
apiVersion: v1
kind: ConfigMap
metadata:
annotations:
labels:
app.kubernetes.io/name: argocd-cm
app.kubernetes.io/part-of: argocd
name: argocd-cm
namespace: argocd
data:
accounts.chlai: apiKey,login #Allow users to login and generate aipkey
users.anonymous.enabled: "true" #Allow anonymous users to log in.

Save and modify to take effect immediately.

The default roles of the system are readonly and admin. To grant the user admin permissions, modify the argocd-rbac-cm configmap:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/name: argocd-rbac-cm
app.kubernetes.io/part-of: argocd
name: argocd-rbac-cm
namespace: argocd
data:
policy.csv: |-
g, chlai, role:admin
policy.default: role:readonly #Anonymous login uses the readonly role by default.

To generate a login password, you need to use the admin user cli method to log in to the server and modify it through the argocd account update-password command:

1
2
3
4
5
6
argocd login <argocd-server>
argocd account list
argocd account update-password \
--account <name> \
--current-password <current-admin> \
--new-password <new-user-password>

Log in to the argocd web ui using the new user password.

argocd

ArgoCD UI interface to create an application

Click the “+ NEW APP” button to create an application; argocd

Fill in the application name: guestbook; project: default; synchronization strategy: manual;

argocd

Configure the source. Here, Git is configured, and the URL of the code repository is configured as the project address on Github is: https://github.com/argoproj/argocd-example-apps.git; Revision selection: HEAD; Project path selection: guestbook;

argocd

Select the target cluster for application deployment: https://kubernetes.default.svc, because this time Argo CD is deployed in the Kubernetes cluster, by default Argo CD has already added the current Kubernetes cluster for us, so we can use it directly. Namespace selection: my-app. Namespcae can be created using the # kubectl create namespace my-app command on the Kubernetes cluster;

argocd

After filling in, click the “CREATE” button to create;

argocd

Since the application has not been deployed and the Kubernetes resources have not been created, the Status is still OutOfSync, so we also need to click the “SYNC” button to synchronize (deploy). You can also install the argocd client and use the Argo CD CLI to synchronize :# argocd app sync guestbook

argocd

The application is created and is in the “unsynchronized” state. Manually synchronize the application and start deploying the application argocd

Wait for the application to be created argocd

View the application in the Kubernetes cluster

argocd