K8s Deployment Lifecylce.
Below are the steps should follow to deploy the application in K8’s.
- Creation of Project in the Flux repository. In Simple creating a folder with the API name and Copy all the deployment config template files. (deployment.yml,hpa.yml,ingress.yml,ingress-cname.yml,service.yml & kustomization.yml)
https://github.com/Maersk-Global/smds-opsmdm-infra-flux/tree/main/data/cdt/gda-np-ne-01/overlays
- Update the Secrets in the secrets.yml file. Secret creation steps are mentioned in other document
- Create the CICD for K8s deploy in the Github Application repo. Docker Build and Deploy pipeplines mentioned below. Custom SMDS Github actions are available for easy deployments. Just need to mention Project Name and Image Name in the pipeline.
docker-build: name: Docker Build and Push runs-on: ubuntu-latest needs: build steps: - name: Run image build and deploy action uses: maersk-global/smds-github-actions/harbor-docker-build@main with: harbor_user: ${{ secrets.HARBOR_USER }} harbor_push_token: ${{ secrets.HARBOR_PUSH_TOKEN }} image_name: ${{ env.IMAGE_NAME }} dockerfile: ./Dockerfile version_number: ${{ env.VERSION_NUMBER }}
cdt-deploy-we: needs: docker-build runs-on: ubuntu-latest steps: - name: Run k8s deploy action - CDT Deploy uses: maersk-global/smds-github-actions/deploy-k8s@main with: infra_repo_name: ops access_token: ${{ secrets.EE_CHECKOUT_TOKEN }} k8s_cluster: ${{ env.CLUSTER_NAME_WE }} vault_name: ${{ env.VAULT_NAME }} vault_role_id: ${{ secrets.VAULT_ROLE_ID }} vault_role_secret: ${{ secrets.VAULT_ROLE_SECRET }} project_name: ${{ env.PROJECT_NAME }} image_name: ${{ env.IMAGE_NAME }} version_number: ${{ env.VERSION_NUMBER }}
- Check the Repo is onbaorded with Harbor. In Github secrets , check HARBOR_USER and HARBOR_PUSH_TOKEN is updated. Check the Harbor Repository Onboard Document to get it clarified.
- kubectl file creation and review.
Template are available for the K8s deployment files creation. We need to provide just inputs to create the deployment file and send it for approval before deploy. Below are the steps to create the files.
a. Synch the Flux repo to local https://github.com/Maersk-Global/smds-opsmdm-infra-flux
b. create a folder under each cluster with the application name
main → data → cdt (enviroment) → gda-np-ne-01 (Cluster) → overlays -> <Projectname>
c. Now copy and replace the values in the templates specific to the Project.
Copy Files : deployment.yml,hpa.yml,ingress.yml,ingress-cname.yml,service.yml & kustomization.yml
d. In Local navigate to the porject Folder and execute the below command to create the kubectl file for review.
kubectl kustomize .
- Post review, Deploy the Application using the CICD. Refer Accessing Cluster page for more info on connecting to the Pods