Skip to content

Latest commit

 

History

History
144 lines (104 loc) · 4.76 KB

File metadata and controls

144 lines (104 loc) · 4.76 KB

0. What does Kubernetes do?

1. K8s Components

k8s docs.

  • Types of machines in a k8s cluster:
    • control plane node(s) (or just called control plane),
    • worker nodes (or just called nodes).
  • control plane has
    • kube-apiserver: k8s API frontend,
    • etcd: key-value store for cluster data,
    • kube-scheduler: assigns resources to nodes based on current constraints,
    • kube-controller-manager: several control loops in one process,
    • cloud-controller-manager: several cloud-specific control loops in one process.
  • worker nodes have
    • kubelet: manages containers deployed to that node,
    • kube-proxy: manages network rules on nodes,
    • Container Runtime: what runs the containers. Any implementation of the K8s Container Runtime Interface (e.g., CRI provided for Docker is the most common).

2. K8s API Objects

  • Abstraction of Workload:
    • Pod: smallest deployable unit — holds one or more containers and runs it in a shared context
    • Workload resources: Used to manage groups of Pods
      • Deployment: for managing stateless Pods
        • ReplicaSet: abstraction to manage a number of identical Pods. Typically not used directly.
      • StatefulSet: for managing stateful Pods (e.g., DBs)
  • Abstraction of Storage
    • Volume: many types of volumes provided by plugins (local, network/distributed FS, cloud)
  • Abstraction of Networking
  • Abstraction of Configuration

3. K8s

Install minikube and kubectl

Minikube

  • minikube start

  • kubectl get nodes

  • minikube status

  • kubectl version

  • minikube delete

Kubectl

  • kubectl get nodes

  • kubectl get pod

  • kubectl get pod -o wide

  • kubectl get services

  • kubectl create deployment nginx-deploy --image=nginx

  • kubectl get deployment

  • kubectl get replicaset

  • kubectl edit deployment nginx-deploy

  • kubectl logs [pod]

  • kubectl exec -it {pod} -- bin/bash

  • kubectl delete deployment nginx-deploy

MongoDB deployment

  kubectl apply -f mongodb/mongo-secret.yaml
  kubectl apply -f mongodb/mongo.yaml
  kubectl apply -f mongodb/mongo-configmap.yaml 
  kubectl apply -f mongodb/mongo-express.yaml
  kubectl get pod
  kubectl get pod --watch
  kubectl get pod -o wide
  kubectl get service
  kubectl get secret
  kubectl get all | grep mongodb
  kubectl describe pod mongodb-deployment-xxxxxx
  kubectl describe service mongodb-service
  kubectl logs mongo-express-xxxxxx
  minikube service mongo-express-service

4. Patterns / Applications

5. Alternatives

Other resources