Giter VIP home page Giter VIP logo

kubernetes-demo's Introduction

kubernetes-demo

This is the repository which shows how to get started with Kubernetes and has some basic commands and config files that you may need.


Basic components

  • Pod - A thin wrapper around one or more containers
  • Node - The machines in a Kubernetes cluster
  • Service - Provides a fixed IP address to a logical group of pods
  • Ingress - An API object that manages external access to the services in a cluster, typically HTTP (DNS)
  • ConfigMap - To store the configurtions
  • Secret - To store the access key and secret or username or password
  • Volumes - To have an external storage space
  • Deployment - Responsible for how to roll out or roll back across versions of your app
  • ReplicaSet - Ensures a defined number of pods are always running
  • StatefulSet - For stateful apps like DB

Control plane

  • One or More API Servers: Entry point for REST / kubectl
  • etcd: Distributed key/value store
  • Controller-manager: Always evaluating current vs desired state
  • Scheduler: Schedules pods to worker nodes

Data plane

  • Made up of worker nodes
  • kubelet: Acts as a conduit between the API server and the node
  • kube-proxy: Manages IP translation and routing

Basic parts of the config.yml file

  1. metadata : Has the name & labels For eg -
metadata:
  name: nginx-deployment
  labels:
    app: nginx
  1. spec : Has the config specific to the kind i.e. whether we are writing the config file for a deployment or service. For eg -
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.16
        ports:
        - containerPort: 8080

  1. status : Auto generated by the kubernetes. Maintains the acutal and desired state here and updates the state continously. The information comes from etcd.

Other useful tags

  • Template : In deployment config, it has its own metadata and spec which defines the pod. For eg -
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.16
        ports:
        - containerPort: 8080
  • Labels : In deployment config, it is there in metadata of both the deployment and the pods.
      labels:
        app: nginx
  • Ports: In deployment & service config, it is there in spec to mention the port. Service target port should be the container port.

    • For container -
        ports:
        - containerPort: 8080
    
    • For service -
    ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
    
  • Selectors : In service config, it is used to make the connection between service and depolyment or its pods.

  selector:
    app: nginx


For setup


create minikube cluster

minikube start --vm-driver=docker
kubectl get nodes
minikube status 
kubectl version

Delete the minikube cluster

minikube delete
minikube status

Install Ingress Controller in Minikube

minikube addons enable ingress
kubectl get pod -n kube-system

Basic kubectl commands

Create deployment

kubectl create deployment {deployement-name} --image={image-name}
For eg - kubectl create deployment nginx-depl --image=nginx

Similarly,
kubectl edit deployment {deployment-name}
For eg - kubectl edit deployment nginx-depl

Delete deployment

kubectl delete deployment {deployment-name}

Create or edit the deployment config.yml

For example - If we try to make it for nginx, we need to follow the below steps -

vim nginx-deployment.yaml
kubectl apply -f nginx-deployment.yaml
kubectl get pod
kubectl get deployment

To delete using config

kubectl delete -f nginx-deployment.yaml

Get commands for various components

kubectl get nodes
kubectl get pod
kubectl get deployment
kubectl get replicaset
kubectl get services
kubectl get all -n {namespace-name}

Logs for debug

kubectl logs {pod-name}
kubectl exec -it {pod-name} -- bin/bash

kubernetes-demo's People

Contributors

kaumudigupta avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.