diff --git a/.gitignore b/.gitignore index 574abe6..8db2bd7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -/password.txt +/password*.txt /*.secret.yaml diff --git a/README.md b/README.md index 9457973..0412ee0 100644 --- a/README.md +++ b/README.md @@ -1,136 +1,163 @@ # ArgoCD Cli installation -On the operator machine: +For test purpose, you can use minikube. Otherwise, use a rancher cluster. + +On the operator machine, one must have the argocd tool installed: ``` curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 chmod +x /usr/local/bin/argocd ``` # ArgoCD installation On the cluster: ``` export NS=argocd kubectl create namespace $NS kubectl apply -n $NS \ -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml ``` -# Access The Argo CD API Server +## minikube + +### Access Argo CD API Server By default, the Argo CD API server is not exposed with an external IP. To access the API server, expose the Argo CD API server through the service type Load Balancer: ``` kubectl patch svc argocd-server -n $NS -p '{"spec": {"type": "LoadBalancer"}}' ``` +### port-forward + +``` +kubectl port-forward services/argocd-server 8080:443 -n $NS +``` + +### ingress controller + +You will also need to enable the ingress controller: +``` +$ minikube addons enable ingress +``` + +## Standard + +We'll use an ingress to access the dashboard: +``` +kubectl apply -n $NS -f dashboard/ingress.yaml +``` + +Use one of the dns records (associated to the ip below) to access your dashboard: +``` +kubectl get ingress -A +NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE +argocd argocd-server * $ip_0,$ip_2,...,$ip_n 80 29m +``` + # Store ArgoCD admin dashboard +Copy the password in your clipboard (and try and connect to the dashboard: ``` kubectl -n $NS get secret argocd-initial-admin-secret \ - -o jsonpath="{.data.password}" | base64 -d > password.txt + -o jsonpath="{.data.password}" | base64 -d | xsel --input --clipboard ``` # Change ArgocCD admin login password ``` -# example: argocd login localhost:8080 +# examples: +# - ARGOCD_SERVER=localhost:8080 +# - ARGOCD_SERVER=argo-worker01.internal.admin.swh.network:443 argocd login $ARGOCD_SERVER argocd account update-password ``` -Note: -With minikube, you will need the following port-forward: - -``` -kubectl port-forward services/argocd-server 8080:443 -n $NS -``` - Note: The password must be a string of characters between [8-32] characters. # Custom configuration We need to retrieve the cluster configurations we want argocd to discuss with out of the rancher ui [1]. For each cluster, we want to create the following yaml file: ``` apiVersion: v1 kind: Secret metadata: # must match $NS at the top of the readme namespace: argocd name: $environment-cluster-config labels: argocd.argoproj.io/secret-type: cluster type: Opaque stringData: name: $CLUSTER_NAME server: $CLUSER_URL config: | { "bearerToken": "$CLUSTER_TOKEN", "tlsClientConfig": { "insecure": false, "caData": "$CLUSTER_CERTIFICATE" } } ``` where the $variable are extracted out of the retrieve yaml configuration: - CLUSTER_NAME: e.g. deployment-internship - CLUSTER_URL: e.g. https://rancher.euwest.azure.internal.softwareheritage.org/k8s/clusters/c-fvnrx - CLUSTER_TOKEN: authentication token of the cluster (from clusters > users > $cluster-name > user > token) - CLUSTER_CERTFICATE: extracted out (from clusters[0] > cluster > certificate-authority-data) Custom cluster-config.yaml file to add to a new cluster: ``` kubectl apply -f cluster-config.secret.yaml ``` [1] https://rancher.euwest.azure.internal.softwareheritage.org/ ("download kubeconfig") # Jenkinsfile in "charts_code/worker" directory - Custom this fields - credentialsID - passwordVariable - usernameVariable - Custom sh commands # Jenkinsfile in "image_code" - Custom stage # Values files - Custom values files - myvalues.yaml - ranchervalues.yaml - myvalues.yaml # Custom argocd app file - Custom stag_app_deployment.yaml - Custom production_app_deployment.yaml # Create stag argocd app ``` -kubectl apply -f stag_app_deployment.yaml +kubectl apply -f staging-app-deployment.yaml ``` # Create production argocd app ``` -kubectl apply -f production_app_deployment.yaml +kubectl apply -f production-app-deployment.yaml ``` diff --git a/dashboard/ingress.yaml b/dashboard/ingress.yaml new file mode 100644 index 0000000..6b69380 --- /dev/null +++ b/dashboard/ingress.yaml @@ -0,0 +1,24 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: argocd-server + namespace: argocd + annotations: + #cert-manager.io/cluster-issuer: letsencrypt-prod + kubernetes.io/ingress.class: nginx + kubernetes.io/tls-acme: "true" + nginx.ingress.kubernetes.io/ssl-passthrough: "true" + # If you encounter a redirect loop or are getting a 307 response code + # then you need to force the nginx ingress to connect to the backend using HTTPS. + nginx.ingress.kubernetes.io/backend-protocol: "HTTPS" +spec: + rules: + - http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: argocd-server + port: + name: https