Let’s Talk: Containers and Kubernetes In Google Cloud Platform — Part 2

Samuel Arogbonlo
Apr 7 · 5 min read

Referencing Part 1, we were able to understand the need for Kubernetes in the world of container orchestration. In this phase of the journey, we will talk a bit about nodes, kubectl, deployment and many other interesting Kubernetes concepts.

Nodes

There are node pools that are a sub of the main nodes (they share workloads and other resources and it's more of a GKE feature than Kubernetes). Meanwhile, there are two types of cluster formats; Zonal and Regional. In context, the zonal cluster has a zone with a cluster, master and nodes for the application functionality — if the cluster or zone shuts down, the application might go down but for regional cluster covers such issues as the cluster is cut across three zones in the same region such that if any part of the cluster fails, the other keeps the job going. P.S: There is also a chance to do a private cluster and it has only access privately using GCP services or authorized networks but not open to the internet.

Zonal & Regional Cluster

Kubernetes Object Management

apiVersion: apps/v1
kind: Pod
metadata:
name: nginx
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest

Best Practices: Learn to save the YAML file in the repository for version control from the cloud then of course you can also track and manage changes. Also, the objects must have unique names that could be string and it must be unique. There is also a unique ID for all the life of the cluster. Labels help identify objects and a subset of objects and could be sampled thus:

apiVersion: apps/v1
kind: Pod
metadata:
name: nginx
labels:
app: nginx
env: dev
stack: frontend
spec:
replicas: 3
selector:
matchLabels
app: nginx

Pods

Deployment and NameSpaces

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deploement
labels:
app: nginx
spec:
replicas: 3
template"
metadata:
labels
app: nginx
spec:
Containers:
- name: nginx
image: nginx:latest

Best Practice: You can apply a resource to a namespace when creating it, using a command-line namespace flag. Or, you can specify a namespace in the YAML file for the resource. Whenever possible, apply namespaces at the command line level. This practice makes your YAML files more flexible. For example, someday you might want to create two identical but completely independent instances of one of your deployments, each in its own namespace. This could be the case if you want to deploy into separate namespaces for testing before deploying into production. This is difficult if you have chosen to embed namespace names in your YAML files.

Service

It works with a label selector for the pods’ communication and somehow sidelines the ephemeral nature of the pods IP. Also, endpoint resources is created as well then the virtual IP address used.

If you want storage shared between two pods/clusters within a container then it may be an issue because of the nature of the cluster. Kubernetes volume is a directory that is accessible to all the containers in a pod and its requirements can be decided using pod specifications and you must mount these volumes specifically on each container within a pod and you can set up volumes from external storage outside the pods for durable storage authenticity.

Best Practice: Volumes are ephemeral because if the pods are deleted, they could be deleted so you could configure the volume with network based storage outside of the pods.

There are other concepts and definitions to be addressed but it will be better in some topics to come because it will relate directly to the focus of that part. Now, remember, this article is not only for experts in the cloud space, even newbies could hop in and learn a lot and that is why I make everything clear both in layman and professional terms, so if you have any questions, shoot or you can also reach out to me on Twitter or find me on Github.

Thanks for reading ❤️

Please leave a comment if you have any thoughts about the topic — I am open to learning and knowledge explorations.

I can imagine how helpful this post has been, do leave a clap 👏 below a few times to show your support for the author!

Nerd For Tech

From Confusion to Clarification

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store