Skip to content

Instantly share code, notes, and snippets.

@GeoffMahugu
Last active August 6, 2020 20:10
Show Gist options
  • Save GeoffMahugu/eb3015cf0165ae6dcb0417af1e0ef91f to your computer and use it in GitHub Desktop.
Save GeoffMahugu/eb3015cf0165ae6dcb0417af1e0ef91f to your computer and use it in GitHub Desktop.
AgilionCluster.md

AGILION K8S CLUSTER MAINTAINACE

This document contains descripion on how to maintain agilion's cluster.

Key Assumptions

* Basic understanding of kubernetes(k8s) and microservice architecture.
* Cluster is up and running (There will be commands to verify the cluster status)
* Master Node configuration:
  -- RAM       >= 2 GB 
  -- PROCESSOR >= 2 GB
 

NAMESPACES

SERVER_IP                = 192.168.100.119
SERVER_KS8_PORT          = 6443
DEPLOYMENT_IMG_URL       = FOR DEV : registry.gitlab.com/agilion/agilion-server/travel/dev
                         = FOR PROD: registry.gitlab.com/agilion/agilion-server/travel/prod


STEP 1: Access Server

You may decide to use ssh/putty as long as you gain access to the terminal. In my case that would be:

ssh [email protected]

STEP 2: Check Server Status

Check K8s cluster status:

kubectl cluster-info

Desired response should be:

Kubernetes master is running at https://<SERVER_IP>:<SERVER_KS8_PORT>
KubeDNS is running at https://<SERVER_IP>:<SERVER_KS8_PORT>/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

STEP 3: Check Nodes

This command is to check for running nodes. (Nodes are like the physical machines)

kubectl get nodes

STEP 4: Check Services

This command is to check for running services.

kubectl get services

For Hidden & detailed output:

kubectl get services --all-namespaces -o wide

STEP 5: Check Deployments

This command is to check for running deployments. (Deployments are the services that we want to run on K8s, the various applications)

kubectl get deployments

For Hidden & detailed output:

kubectl get deployments --all-namespaces -o wide

STEP 6: Update A Deployment.

This command will ensure a new deployment is built onto the cluster.

If deployment.yaml file is present on the cluster, run this command.

kubectl apply -f deployment.yaml

If you have access to docker-hub where the build is hosted, run this command.

kubectl apply -f < DEPLOYMENT_IMG_URL >

STEP 7: Update A Service.

This command will ensure a new service is built onto the cluster.

If service.yaml file is present on the cluster, run this command.

kubectl apply -f service.yaml

Otherwise, the only service we are running does not have to be updated.

DASHBOARD

This is where we do all the server maintainace activities (Scale, update and destroy nodes & pods). To access the dashboad you will need 2 things: DASHBOARD URL & ACCESS TOKEN

BROWSER: FIREFOX

URL: https://192.168.1.119:30293/#/login

TOKEN:

eyJhbGciOiJSUzI1NiIsImtpZCI6InBocmd5RWc0d1NodzRSMmNRamFnUzRGT0lPN0RMc3ZjTjJMam9LYnJQZEUifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6ImRhc2hib2FyZC10b2tlbi12d3RucCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJkYXNoYm9hcmQiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiIzMGZkYTcxOC00MWMwLTQzODktYjNiYy0yNzhjNzUwMTE2MGUiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6ZGVmYXVsdDpkYXNoYm9hcmQifQ.KuAJabMVO9wa2Yo9w_4bgop6vs34_yazaactTp0IFaeLcgtLBuCzGgQWpK1nZRdS2eY8mhb5Hy_YGXA7DzRQvXuRR55Xh7xgtIoG2qvvya_QOBtHelv4LWQJciaw8-Bv7Rrja_1UdpkWHu7dppAJVddsaj0sjmM32jDSuWN9p11had13YlLcKNFE5j2AaYp8HDOjnjRgcric_3hXHXKumfDl7K5YWvdR_EnvLVWt0lgv-zG-_XfidayRwyNaJYcMZDYPXH3eHqWhWlOxbEcw1Sc3xKfng1cWb6cLcMKtoqEDuTbiPYOQVxHttJFZTlccbdSGN1rnDfOvC-qQxYmXkg

To refresh token:

kubectl get secret $(kubectl get serviceaccount dashboard -o jsonpath="{.secrets[0].name}") -o jsonpath="{.data.token}" | base64 --decode

MAINTAINANCE

DELETE A DEPLOYMENT

This command will delete a deployment.

Use the command to get all deployments will detailed description to get the NAMESPACE

kubectl delete deployment < NAMESPACE >

Force delete a deployment.

kubectl delete deployment < NAMESPACE > --force

FOR MORE DOCUMENTATION

For more documentation on Docker & KUBERNETES SETTUP you can READ-MORE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment