Step 7 Setup Continuous Delivery (CD) - truongnhatbui/techtrends GitHub Wiki
Continuous Delivery (CD) is the ability to get code changes reliably to production environments. This practice should be automated and should enable developers to provide value to consumers efficiently.
In this exercise, you will use ArgoCD to automate the delivery of techtrends application to a Kubernetes cluster.
Prepare the environment to create your delivery pipeline.
Note: Make sure to have VirtualBox installed. Make sure task list completed https://github.com/truongnhatbui/techtrends/wiki/Step-3-Deploy-Kubernetes-Cluster
Now that you have a Kubernetes cluster up and running, let's deploy techtrends application using ArgoCD.
Step 1 - Install ArgoCD by referring to the installation guide
Step 2 - Expose the argocd-server
using a NodePort
service on port 30007
on HTTP and 30008
on HTTPS. The YAML manifest for the NodePort service can be found in the techtrends repository
The following snippet highlights the commands to deploy ArgoCD and expose it using a NodePort service:
# deploy ArgoCD
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
# Create the NodePort service for ArgoCD server by using the
# `kubectl apply -f argocd-server-nodeport.yaml` command
apiVersion: v1
kind: Service
metadata:
annotations:
labels:
app.kubernetes.io/component: server
app.kubernetes.io/name: argocd-server
app.kubernetes.io/part-of: argocd
name: argocd-server-nodeport
namespace: argocd
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 8080
nodePort: 30007
- name: https
port: 443
protocol: TCP
targetPort: 8080
nodePort: 30008
selector:
app.kubernetes.io/name: argocd-server
type: NodePort
The Nodeport service for ArgoCD can be found in the techtrends repository.
Step 3 - Access the ArgoCD UI by going to https://192.168.50.4:30008
or, https://192.168.50.4:30007
pass the warning and reach the Log-in page
Step 4 - Insert login credentials, by using credentials guide
The initial password for the admin account is auto-generated and stored as clear text in the field password in a secret named argocd-initial-admin-secret in your Argo CD installation namespace. You can simply retrieve this password using kubectl:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
For better readability, e.g. if you want to copy & paste the generated password, you can simply append && echo to above command, which will add a newline to the output.
Warning - You should delete the argocd-initial-admin-secret from the Argo CD namespace once you changed the password. The secret serves no other purpose than to store the initially generated password in clear and can safely be deleted at any time. It will be re-created on demand by Argo CD if a new admin password must be re-generated.
Using the username admin and the password from above, login to Argo CD's IP or hostname:
argocd login <ARGOCD_SERVER>
Change the password using the command:
argocd account update-password
Step 5 - Create an ArgoCD application named techtrends
and use the manifests provided in the techtrends repository
Once logged in to the ArgoCD server, applications can be created. The declarative manifest for techtrends Application CRD can be found below:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: techtrends
namespace: argocd
spec:
destination:
namespace: default
server: https://kubernetes.default.svc
project: default
source:
path: manifests
repoURL: https://github.com/truongnhatbui/techtrends
targetRevision: HEAD
# Sync policy
syncPolicy: {}