moved to https://gitlab.com/t-systems-devops-school/6-Orchestration
- Access key ID
- Secret access key
- Region
$ aws configure
AWS Access Key ID - XXXXXXXXXX
AWS Secret Access Key - XXXXXXXXXX
Default region name - XXXXXXXXXX
Default output format - json
$ aws eks update-kubeconfig --name school
Or you may use Rancher desktop to setup local Kubernetes cluster!
Minikube is OK as well, but we recommend Rancher as more easy tool.
You will use the image as base image of deployment job. You can insert installation command right in script section of deployment job, but will be much better to create a new git repo to build and store the prepared Docker image.
- In Dockerfile add installtion of tools list:
- Build and push the image in Gitlab registry (or you may use another registry to store the image)
- Use prepared Docker image for deployment job.
- Configure variables in Gitlab group or project level variables:
AWS_REGION= XXXXXXXXXX
AWS_ACCESS_KEY_ID= XXXXXXXXXX
AWS_SECRET_ACCESS_KEY= XXXXXXXXXX
AWS_DEFAULT_OUTPUT= json
- Make cluster connection in
before_script
section:
before_sctipt:
- aws sts get-caller-identity # Check connection
- aws eks update-kubeconfig --name school # Get kube config
script:
- # kubectl or helm or helmfile
If Connecting a Kubernetes cluster with GitLab is working on current moment you may use this connection approach as well.
- Create your Namespace.
- Create a deployment:
- Nginx application with 3 replicas
- Scale down it to 1 replica
- Change Nginx image to another one
- Rollback to previous Nginx deployment with 3 replicas
- Create a staefulset:
- Mongo DB with 3 replicas
- Send screenshots with version of deployment and statefulset in the chat with homework hashtags.
# Apply yaml file
$ kubectl apply -f {YAML_FILE}
# Describe kubernetes object
$ kubectl describe {KUBERNETES_OBJECT_TYPE} {OBJECT_NAME}
# Get kubernetes object info and status
$ kubectl get {KUBERNETES_OBJECT_TYPE} -n {NAMESPACE} [-o wide]
# Deployment rollout history
$ kubectl rollout history deployment {DEPLOYMENT_NAME} -n {NAMESPACE}
# Rollback to previous version of a deployment
$ kubectl rollout undo deployment {DEPLOYMENT_NAME} --to-revision={N} -n {NAMESPACE}
# Get pod's logs
$ kubectl logs {POD_NAME}
# Scaling of ReplicaSet, Deployemnt, Statefulset
$ kubectl scale {KUBERNETES_OBJECT_TYPE} {OBJECT_NAME} --replicas=3 -n {NAMESPACE}
# Edit any kubernetes object as yaml file
$ kubectl edit {KUBERNETES_OBJECT_TYPE}/{OBJECT_NAME} -n {NAMESPACE}
# Get a Shell to a Running Container
$ kubectl exec -it {POD_NAME} -- /bin/sh
# Port forwarding to access a pod with 80 port as localhost:8080 application in browser or terminal
$ kubectl port-forward pods/{NAME_OF_POD} 8080:80
- Run a Stateless Application Using a Deployment
- Running MongoDB on Kubernetes with StatefulSets
- Use Port Forwarding to Access Applications in a Cluster
- Get a Shell to a Running Container
- kubectl Cheat Sheet
- Cleanup your Namespace.
- Create and configure deployment in Gitlab Course project (use the pipelines from CI/CD homework):
- Create Deployment yamls for backend and frontend
- Create Deployment yaml for PostgreSQL DB with 1 replica and 1 PV
- Create Services for all components
- Create Ingress'. For Frontend use host format <NAMESPACE_NAME>.school.telekom.sh
- Add probes
- Add resource requests and limits
- Do deploy from Gitlab by pre-configuring the connection to the Kubernetes cluster in .gitlab-ci.yml
- Check that FE, Backend and DB are working together like entire application:
- Insert a new course entry and a school with random name, then create a user with your name
- Send screenshots of browser with application UI (with the student entry) and URL in the chat with homework hashtags.
- Create in Gitlab another one project for helm charts.
- Create 3 Helm charts for course project components: Backend, Frontend, DB. Charts must include:
- Deployment
- Service
- Ingress
- PVC (for DB)
- In values:
- Image
- Replica counts
- Host for ingress
- Publish charts in Gitlab Helm repository of your git project.
- Create another values.yaml file in Cource project repo to separate Dev and Prod installation:
- Production installation should have 2 replicas for Frontend and Backend
- Development installation should have 1 replicas for Frontend and Backend
- Create additional Namaspace in Kubernetes for Prod deployment.
- Rewrite gitlab-ci.yaml to do helm chart deployment, using charts from Helm repository of helm chart git project.
- Do deployments to Prod and Dev environments in Gitlab pipelines.
- Check Course project application in Dev and Prod envs.
- Send screenshots of published charts from Gitlab registry in the chat with homework hashtags.
- Use helmfile to do deployement to Dev and Prod envs instead of using diffrent values.yaml files with pure Helm:
- Create helmfile.yaml in Course project repository
- Configure releases and values in helmfile.yaml
- Create values.yaml and go templates if necessary for independent Dev and Prod deployemnt
- Rewrite gitlab-ci.yaml to do helmfile deployment
- Do deployment and check
- Send screenshots of helmfile.yaml in the chat with homework hashtags.