Kubernetes on Digital Ocean

After starting Kubernets (configure kubectl automatically):

doctl kubernetes cluster kubeconfig save my-cluster-name

Fix : invalid object doesn’t have additional properties

After installing kubectl with brew you should run:

  1. rm /usr/local/bin/kubectl
  2. brew link --overwrite kubernetes-cli

minikube dashboard

MacBook:~$ minikube dashboard
🔌 Enabling dashboard …
🤔 Verifying dashboard health …
🚀 Launching proxy …
🤔 Verifying proxy health …
🎉 Opening in your default browser…

Describe POD

kubectl describe pod nodehelloworld.example.com

minikube service

MacBook:~/kubernetes-course$ cat first-app/helloworld-service.ymlapiVersion: v1kind: Servicemetadata:name: helloworld-servicespec:ports:- port: 80targetPort: nodejs-portprotocol: TCPselector:app: helloworldtype: LoadBalancerMacBook:~/kubernetes-course$ cat first-app/helloworld-nodeport-service.ymlapiVersion: v1kind: Servicemetadata:name: helloworld-servicespec:ports:- port: 31001nodePort: 31001targetPort: nodejs-portprotocol: TCPselector:app: helloworldtype: NodePortMacBook:~/kubernetes-course$ kubectl create -f first-app/helloworld-nodeport-service.ymlservice/helloworld-service createdMacBook:~/kubernetes-course$ minikube service helloworld-service --urlhttp://$ curl World!
Hello World!MacBook:~/kubernetes-course$ kubectl describe svc helloworld-serviceName:                     helloworld-serviceNamespace:                defaultLabels:                   <none>Annotations:              <none>Selector:                 app=helloworldType:                     NodePortIP:                                  <unset>  31001/TCPTargetPort:               nodejs-port/TCPNodePort:                 <unset>  31001/TCPEndpoints:       Affinity:         NoneExternal Traffic Policy:  ClusterEvents:                   <none>MacBook:~/kubernetes-course$ kubectl get svc helloworld-serviceNAME                 TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)           AGEhelloworld-service   NodePort   <none>        31001:31001/TCP   3m14s


apiVersion: v1kind: Podmetadata:name: nodehelloworld.kubernetes.intelligence.wslabels:app: helloworldspec:containers:- name: docker-demoimage: joelgriffiths/docker-demoports:- containerPort: 3000
kubectl create -f pod-hellowworld.yml

Useful commands

kubectl get pod

kubectl describe pod

kubectl expose pop <pod> –port=444 –name=frontend

kubectl port-forward <pod-name> 8080

kubectl attach <pod-name> -i

kubectl exec <pod-name> – command    # First container

kubectl exec <pod-name> -c <container> – command

kubectl label pods <pod-name> mylabel=awesome


kubectl run -i –tty busybox –image=busybox –restart=Never – sh

POD Commands in hello world example

kubectl get pod

kubectl describe pod nodehelloworld.example.com

kubectl port-forward nodehelloworld.example.com 8081:3000

Getting to the POD directly

kubectl expose pod nodehelloworld.example.com –type=NodePort –name nodehelloworld-service
minikube service nodehelloworld-service –url


MacBook:~/kubernetes-course$ kubectl get service


kubernetes ClusterIP <none> 443/TCP 17h

nodehelloworld-service NodePort <none> 3000:32129/TCP 4m

(See logs)

kubectl attach nodehelloworld.example.com

(Execute command)

kubectl exec nodehelloworld.example.com – ls /app

(Describe service)

kubectl get service

kubectl describe service nodehelloworld-service


(Start Busybox POD)

kubectl run -i –tty busybox –image=busybox –restart=Never — sh

    #/ telnet

Joel Griffiths

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top