Skip to content

Latest commit

 

History

History
147 lines (105 loc) · 2.4 KB

README.md

File metadata and controls

147 lines (105 loc) · 2.4 KB

K8S configuration

Getting started

  1. To run in local install minikube and kubectl

  2. Copy .k8s/secret.yaml.txt to .k8s/secret.yaml and configure it

  3. Start minikube

  minikube start
  1. Enable ingress controller
  minikube addons enable ingress
  1. Execute
  sh .k8s/apply.sh
  1. Serve app:
  minikube service languages-app-api-service --url

Docker registry

When we will need to push the image to docker hub we will need this commands:

  docker login 

  docker build -t mapeveri/languages:latest .

  docker tag mapeveri/languages:latest mapeveri/languages:latest

  docker push mapeveri/languages:latest
  1. Copy .k8s/secret.yaml.txt to .k8s/secret.yaml and configure it

Encrypt secret values:

echo -n "my-secret" | base64

Kubernetes Commands Reference

Get Information

  • Nodes:

    kubectl get nodes -o wide # Get internal IP
  • Pods:

    kubectl get pods -n default # Get pods from default namespace
  • Deployments:

    kubectl get deployment # Deployment status
  • Services:

    kubectl get service # Service status

Describe Resources

  • Pod:

    kubectl describe pod app # Pod details
  • Service:

    kubectl describe svc app # Service details

Operations

  • Rollout Restart:
    kubectl rollout restart deployment/languages # Restart pods

Configuration

  • Config Map:
    kubectl get configmap app-config -o yaml # Config map details

Interact with Pods

  • Access Shell:

    kubectl exec -it app -- /bin/bash # Enter the pod
  • List Environment Variables:

    kubectl exec -it app -- env # List pod environment variables
  • Container Logs:

    kubectl logs app # View container logs
  • Create secret:

    kubectl create secret generic languages-app-secret --from-literal=GOOGLE_CLIENT_ID=password
  • Delete secret:

    kubectl delete secret languages-app-secret
  • Display secret value:

    kubectl get secret languages-secret -n default -o jsonpath="{.data.GOOGLE_CLIENT_ID}" | base64 --decode
    
  • Get ingress:

    kubectl get ingress
    
  • Get pods ingress:

    kubectl get pods -n ingress-nginx