Pengertian Node
Node merupakan sebuah mesin worker di dalam Kubernetes, yang sebelumnya dinamakan minion. Sebuah node bisa berupa VM ataupun mesin fisik, tergantung dari klaster-nya. Masing-masing node berisi beberapa servis yang berguna untuk menjalankan banyak pod dan diatur oleh komponen-komponen yang dimiliki oleh master. Servis-servis di dalam sebuah node terdiri dari runtime kontainer, kubelet dan kube-proxy.
Melihat Semua Node
kubectl get node
dwinar@master-kubernetes:~$ kubectl get node NAME STATUS ROLES AGE VERSION master-kubernetes Ready master 53d v1.16.3 node1-kubernetes Ready 53d v1.16.3 node2-kubernetes Ready 53d v1.16.3 dwinar@master-kubernetes:~$
Melihat Detail Node
kubectl describe node namanode
dwinar@master-kubernetes:~$ kubectl describe node master-kubernetes Name: master-kubernetes Roles: master Labels: beta.kubernetes.io/arch=amd64 beta.kubernetes.io/os=linux kubernetes.io/arch=amd64 kubernetes.io/hostname=master-kubernetes kubernetes.io/os=linux node-role.kubernetes.io/master= Annotations: flannel.alpha.coreos.com/backend-data: {"VtepMAC":"b2:c4:d8:9f:97:c2"} flannel.alpha.coreos.com/backend-type: vxlan flannel.alpha.coreos.com/kube-subnet-manager: true flannel.alpha.coreos.com/public-ip: 10.0.2.15 kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock node.alpha.kubernetes.io/ttl: 0 volumes.kubernetes.io/controller-managed-attach-detach: true CreationTimestamp: Sun, 01 Dec 2019 16:30:29 +0700 Taints: node-role.kubernetes.io/master:NoSchedule Unschedulable: false Conditions: Type Status LastHeartbeatTime LastTransitionTime Reason Message ---- ------ ----------------- ------------------ ------ ------- MemoryPressure False Fri, 24 Jan 2020 10:34:14 +0700 Sun, 01 Dec 2019 16:30:24 +0700 KubeletHasSufficientMemory kubelet has sufficient memory available DiskPressure False Fri, 24 Jan 2020 10:34:14 +0700 Sun, 01 Dec 2019 16:30:24 +0700 KubeletHasNoDiskPressure kubelet has no disk pressure PIDPressure False Fri, 24 Jan 2020 10:34:14 +0700 Sun, 01 Dec 2019 16:30:24 +0700 KubeletHasSufficientPID kubelet has sufficient PID available Ready True Fri, 24 Jan 2020 10:34:14 +0700 Sun, 01 Dec 2019 16:34:00 +0700 KubeletReady kubelet is posting ready status. AppArmor enabled Addresses: InternalIP: 192.168.137.2 Hostname: master-kubernetes Capacity: cpu: 2 ephemeral-storage: 19525500Ki hugepages-2Mi: 0 memory: 2047936Ki pods: 110 Allocatable: cpu: 2 ephemeral-storage: 17994700771 hugepages-2Mi: 0 memory: 1945536Ki pods: 110 System Info: Machine ID: c332818dca5d7f02c8dec6b35de36933 System UUID: 04ECCD20-A71A-41B9-989D-0BCC021BB333 Boot ID: 5f5ea100-ec47-47b2-b955-fbf04f0b38a9 Kernel Version: 4.4.0-169-generic OS Image: Ubuntu 16.04.6 LTS Operating System: linux Architecture: amd64 Container Runtime Version: docker://17.3.3 Kubelet Version: v1.16.3 Kube-Proxy Version: v1.16.3 PodCIDR: 10.244.0.0/24 PodCIDRs: 10.244.0.0/24 Non-terminated Pods: (8 in total) Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits AGE --------- ---- ------------ ---------- --------------- ------------- --- kube-system coredns-5644d7b6d9-7vq5b 100m (5%) 0 (0%) 70Mi (3%) 170Mi (8%) 53d kube-system coredns-5644d7b6d9-cxxfx 100m (5%) 0 (0%) 70Mi (3%) 170Mi (8%) 53d kube-system etcd-master-kubernetes 0 (0%) 0 (0%) 0 (0%) 0 (0%) 53d kube-system kube-apiserver-master-kubernetes 250m (12%) 0 (0%) 0 (0%) 0 (0%) 53d kube-system kube-controller-manager-master-kubernetes 200m (10%) 0 (0%) 0 (0%) 0 (0%) 53d kube-system kube-flannel-ds-amd64-lnj6k 100m (5%) 100m (5%) 50Mi (2%) 50Mi (2%) 53d kube-system kube-proxy-d77ct 0 (0%) 0 (0%) 0 (0%) 0 (0%) 53d kube-system kube-scheduler-master-kubernetes 100m (5%) 0 (0%) 0 (0%) 0 (0%) 53d Allocated resources: (Total limits may be over 100 percent, i.e., overcommitted.) Resource Requests Limits -------- -------- ------ cpu 850m (42%) 100m (5%) memory 190Mi (10%) 390Mi (20%) ephemeral-storage 0 (0%) 0 (0%) Events: dwinar@master-kubernetes:~$
Pengertian Pod
Pod adalah unit terkecil yang bisa di deploy di Kubernetes Cluster. Pod berisi satu atau lebih container. Secara sederhana Pod adalah aplikasi kita yang running di Kubernetes Cluster.
Melihat Semua Pod
kubectl get pod
dwinar@master-kubernetes:~$ kubectl get pod NAME READY STATUS RESTARTS AGE myapp-pod 1/1 Running 0 132m dwinar@master-kubernetes:~$
Melihat Detail Pod
kubectl describe pod namapod
dwinar@master-kubernetes:~$ kubectl describe pod myapp-pod Name: myapp-pod Namespace: default Priority: 0 Node: node2-kubernetes/192.168.137.4 Start Time: Fri, 24 Jan 2020 08:22:35 +0700 Labels: app=myapp Annotations: Status: Running IP: 10.244.2.5 IPs: IP: 10.244.2.5 Containers: nginx: Container ID: docker://c8e097fe30e068610f29041efdbd3712f8fd6734e559573b05dc917c2a42e118 Image: nginx Image ID: docker-pullable://nginx@sha256:70821e443be75ea38bdf52a974fd2271babd5875b2b1964f05025981c75a6717 Port: Host Port: State: Running Started: Fri, 24 Jan 2020 08:22:56 +0700 Ready: True Restart Count: 0 Environment: Mounts: /var/run/secrets/kubernetes.io/serviceaccount from default-token-j5zjq (ro) Conditions: Type Status Initialized True Ready True ContainersReady True PodScheduled True Volumes: default-token-j5zjq: Type: Secret (a volume populated by a Secret) SecretName: default-token-j5zjq Optional: false QoS Class: BestEffort Node-Selectors: Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s node.kubernetes.io/unreachable:NoExecute for 300s Events: dwinar@master-kubernetes:~$
Membuat Pod
Buat sebuat file yaml, lalu masukan isikan dengan isian berikut
apiVersion: v1 kind: Pod metadata: name: nginx spec: containers: - name: nginx image: nginx
Jalankan perintah berikut untuk membuat sebuah pod.
kubectl create -f filepod.yaml
Melihat Pod
kubectl get pod
dwinar@master-kubernetes:~$ kubectl get pod NAME READY STATUS RESTARTS AGE myapp-pod 1/1 Running 0 135m dwinar@master-kubernetes:~$
kubectl get pod -o wide
dwinar@master-kubernetes:~$ kubectl get pod -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES myapp-pod 1/1 Running 0 136m 10.244.2.5 node2-kubernetes dwinar@master-kubernetes:~$