Skip to content

Files

Latest commit

ea28043 · Feb 4, 2022

History

History
111 lines (103 loc) · 2.3 KB

depoy_kubernetes.md

File metadata and controls

111 lines (103 loc) · 2.3 KB

Kubernetes CLI

Deployment Process

  1. convert docker-compose for kubernetes
mkdir $HOME/kube
cd $HOME/kube 
kompose convert -f ~/docker-compose/docker-compose.yml
  1. Start minikube & Evaluate
minikube start --insecure-registry="${LOCAL_IP}:5000"
eval $(minikube docker-env)
# for RPI 
minikube -p minikube docker-env
  1. Start processes
kubectl apply -f $HOME/kube

4Stop processes

kubectl delete -f $HOME/kube

Updating Service Information

In cases where standard port-forwarding doesn't work (ex. Minikube), user should attempt to change ClusterIP to NodePort in the

  1. Edit the service you're unable to port-forward against
kubectl edit service ${SERVICE_NAME}
  1. replace ClusterIP to NodePort(using sed)
# before 
  ports:
  - name: "13480"
    nodePort: 31266
    port: 13480
    protocol: TCP
    targetPort: 13480
  - name: "13481"
    nodePort: 31956
    port: 13481
    protocol: TCP
    targetPort: 13481
  - name: "13482"
    nodePort: 31296
    port: 13482
    protocol: TCP
    targetPort: 13482
  selector:
    io.kompose.service: ${SERVICE_NAME}
  sessionAffinity: None
  type: ClusterIP

# after 
  ports:
  - name: "13480"
    nodePort: 31266
    port: 13480
    protocol: TCP
    targetPort: 13480
  - name: "13481"
    nodePort: 31956
    port: 13481
    protocol: TCP
    targetPort: 13481
  - name: "13482"
    nodePort: 31296
    port: 13482
    protocol: TCP
    targetPort: 13482
  selector:
    io.kompose.service: ${SERVICE_NAME}
  sessionAffinity: None
  type: NodePort
  1. Generate IP:PORT to execute against
minikube service --url ${SERVICE_NAME}

Commands

  • list (running) pods
kubectl get pods
  • Access shell node correlated to a specific pod
kubectl exec -it ${POD_NAME} -- /bin/bash
  • Get services
kubectl get services 
  • Describe pod
kubectl describe pod ${POD_NAME}
  • Pod logs - shows program output
kubectl logs ${POD_NAME} 
  • Port-Forwarding
kubectl port-forward --address=${LOCAL_IP} service/${SERVICE_NAME} LOCAL_PORT:REMOTE_PORT