Untitled

https://github.com/ACloudGuru-Resources/Course_Kubernetes_Deep_Dive_NP/tree/master/lesson-code-k8s

Deploying an Image to the Hub

docker image build -t ericchen/my-image:0.1

# See image
docker image ls 

# Login 
docker login 

# Push to Hub, public repo
docker image push ericchen/my-image:0.1 

Never use pod in production, you want something more flexible like a deployment.

Deployment of Application

# web-deploy.yml
# Deployment File of App, pulling from Docker Hub
apiVersion: apps/v1
kind: Deployment
metadata:
  name: simple-web
  labels:
    customer: acg
spec:
  selector:
    matchLabels:
      app: web
  replicas: 3
  strategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
      - image: nigelpoulton/acg-web:0.1
        name: web-ctr
        ports:
        - containerPort: 8080
# Simple deployment on K8s service
kubectl apply -f ./web-deploy.yml

Use NodePort to see it locally

# web-nodeport.yml
apiVersion: v1
kind: Service
metadata:
  name: web-nodeport
  labels:
    app: web
spec:
  type: NodePort
  ports:
    - port: 8080
      nodePort: 31000
  selector:
    app: web

Load Balancer

# web-lb.yml
apiVersion: v1
kind: Service
metadata:
  name: web-svc
  labels:
    app: web
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: web