Brain dump of various kubernetes/
kubectl things before I forget them all.
I’m coming from the deploying analytics side, not the person who sets
up kubernetes side, so this will be a list of useful day 1 type stuff
for anyone who is learning kubernetes practically via deployments
service- something with an IP/hostname you want to hit, e.g. a RESTful front end.
deployment- powers a
serviceby specifying things like number of instances, and how ports are shuffled.
pods- basic atomic-ish unit that make up a deployment. An instance.
Suppose you want to stand up your RESTful analytic with 8 instances,
foo.internal.com. Start with a service, then a deployment.
Pods come via the deployment.
pacman -S kubectl
Get config file from ops-type person. Put or link in
kubectl config show
to make sure you’re running with the correct one.
Change contexts, if needed, for various projects.
kubectl get pods kubectl delete pod ...
You can delete a pod to have K8s immediately kick another one off, useful for getting info about why things aren’t working
kubectl logs pod-name kubectl logs pod-name --previous
Get logs, or see why app crashed before via
--previous. Anything else,
you probably need some log aggregation service (Helm/fluentd?)
kubectl deploy -f ./service.yaml kubectl get services
Deploy services, which are sort of the interface between pods/containers and the rest of the cluster (and outside world).
kubectl deploy -f ./deployment.yaml kubectl delete deployment your-deployment
Deployments power services by specifying instances and memory, ports, docker images, etc.
Interaction outside cluster
kubectl port-forward services/your-service 8080:8080
Test whether or not your API/service/deployments actually work.
Next up: how Terraform does all this for you.