Posts

Showing posts with the label k8s

Check logs when happening errors in the process of creating container

  kubectl -n timesheet-batch-beta describe pod timesheet-batch-deployment-86db85f8cb-hkrlt

Assign pods to nodes

 https://kubernetes.io/docs/tasks/configure-pod-container/assign-pods-nodes/

Check worker node usage

  Use the following commands to check workload usage in CLI: kubectl top pod kubectl describe pod NAME                             CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%     node-1   185m         11%     2671Mi           39%         node-2   145m         9%     2755Mi           40%         node-3   177m         11%     2767Mi           40%         coax-1         1137m         31%     3132Mi           45%         coax-2         107m         2%     1969Mi           28%     ...

Service account token

1. => tạo service account kubectl create serviceaccount deployer 2. => tạo binding giữa service accounts và role-admin kubectl create clusterrolebinding deployer-binding --clusterrole=cluster-admin \ --serviceaccount= default :deployer 3. => Tạo token với name deployer-secret và attach vào service account deployer kubectl apply -f - <<EOF apiVersion: v1 kind: Secret metadata: name: deployer-secret annotations: kubernetes.io/service-account.name: deployer type: kubernetes.io/ service-account-token EOF 4. => hiển thị danh sách tên các token đã được tạo ra kubectl get secrets 5. => view token value cho deployer đã tạo kubectl describe secret deployer-token-nmx8l https: //cloudhedge.io/setting-up-kubernetes-api-access-using-service-account/

Install ingress nginx controller

  1. helm repo add stable https://charts.helm.sh/stable 2. kubectl create namespace ingress-nginx 3. helm install -n ingress-nginx ingress-controller \ --set rbac.create=true,\ controller.service.externalTrafficPolicy="Local",\ controller.service.nodePorts.http=30080,\ controller.replicaCount=3 \ stable/nginx-ingress

How to scale pod in Kubernetes

 https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics

The difference between ReplicaSet and ReplicaController Deployment, Service, Pod

1. Pod là thành phần đơn giản nhất: Nó như là 1 unit mà sẽ khởi chạy container Trong 1 pod có thể chạy nhiều containers và share chung 1 network apiVersion : batch/v1 kind : Job metadata : name : hello spec : template : # This is the pod template spec : containers : - name : hello image : busybox command : [ 'sh' , '-c' , 'echo "Hello, Kubernetes!" && sleep 3600' ] restartPolicy : OnFailure # The pod template ends here 2. Tiếp theo để 1 pod chạy trên 1 port có thể giao tiếp với các pod khác trong 1 cluster thì cần phải expose nó như 1 service -> Service ra đời để mapping port của Pod ra port service mà các Pod khác có thể connect được với nhau apiVersion : v1 kind : Service metadata : name : my-service spec : selector : app : MyApp ports : - protocol : TCP port : 80 targetPort : 9376 3. Vậy để quản lý việc nhân bản Pod khi scale...

Kubernetes tutorial

 -deployment.yaml apiVersion : apps/v1 kind : Deployment metadata : name : speaker namespace : opentracing annotations : kubernetes.io/change-cause : Change /healthzs to /healthz spec : selector : matchLabels : app : speaker replicas : 1 template : metadata : name : speaker labels : app : speaker spec : containers : - name : speaker image : harbor. google .com/porta-test/speaker:1.1.0 imagePullPolicy : Always livenessProbe : httpGet : path : /healthz port : 8081 httpHeaders : - name : X-API-KEYS value : Awesome-12aswq123 initialDelaySeconds : 3 periodSeconds : 5 ports : - name : speaker containerPort : 8081 protocol : TCP env : - name : LOG_LEVEL_SETUP valueFrom : configMapKeyRef : name : env-config key...