When deciding on breaking down monolithic applications for a micro-services approach, take good inventory of your technical depth of your team. Kubernetes will unlock an entire universe of possibilities with many plugins, repos, and products to choose from you might be asking yourself where do I begin.
When deciding AKS/EKS/GKE determine on how much do you want to manage the infrastructure? Many of the managed services of Kubernetes provide management, support, and native integration to the cloud service provider that might give you an advantage depending on your use-case.
For this simple demo, I’ve spun a AKS cluster with 1 node and will show some basics to get you going, since I’m not the biggest fan of imperatively declaring my YAML file line by line and usually like to do things a little easier we will cover some declarative command line to show you have to avoid it. This doesn’t mean skip over the importance of understanding the YAML format, as this should be your friend.
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
environment: development
app: nginx
spec:
containers:
- image: nginx
name: nginx
After we deploy our AKS service we will access the cloud shell I prefer using bash terminal and the cloud shell will get you up and running.
After setting the .kube/config context we should be able to access the control plane.
kubectl get pods
This will call the API to return to you the pods that are running.
Default namespace doesn’t have resources in it currently so we know in the default namespace nothing is running currently but what are namespaces?
Namespaces can be obtained by the following command
kubectl get namespaces
kubectl get pods -n calico-system
So as we can see the namespaces of calico-system has three pods running on it, the namespaces separate environments, think of certain resources segmented from others.
To deploy our file that we’ve outlined earlier we will add that to a file by listing using vi get familiar with this as you’ll need this for editing files you can also use others such as nano.
vi nginx.yaml
To exit this and save hit (Esc) + :wq! (Enter) this should save this and now we can apply this
kubectl apply -f nginx.yaml
Now let’s get our pods and list this one.
We are up and running you’ve just deployed in AKS!
Next we’ll deploy without writing any yaml a little trick so you won’t have to do this manually by the next command.
For this I’ve created a namespace called runner and will deploy to this environment.
kubectl run akspod --image=nginx -n runner --dry-run=client -o yaml > runner.yaml
Now let’s take a peak at that file by using “cat runner.yaml”
Since I’ve added the “-n” this placed the pod in the namespace.
Now after you run kubectl apply -f runner.yaml you’ll see below
Just a couple of things Kubernetes is large and just this one post doesn’t do it justice enough but the best part is you should be using these commands more often as you learn this complex technology and its various use cases.