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

Samuel Arogbonlo
Apr 7 · 4 min read

Right after understanding the concepts and how the basics of the system run, it is expedient that we learn how to architect workloads with GKE but in the meantime, if you have not read my first articles, check here and here

Google will handle the kubectl command, inspect cluster and pods, view a pod’s console output and sign in to a pod interactively. Kubectl command is what is used to control Kubernetes clusters. Before any further work, kubectl must be configured with the location and the API server of the cluster. In a case where an admin wants to know the number of pods in a cluster, the admin can use the command to communicate with the cluster

kubectl get pods

The lifecycle of such process is shown below:

Kubectl stores in a configuration in a file via a home directory:

$HOME/.kube/config

It contains the cluster name and credentials for the clusters. To view the config, you can use

kubectl config view 

You have to retrieve the credentials of the clusters first before taking any major step. Retrieve your credentials for the specific cluster first. Both of these tools are installed by default in the cloud shell. The G Cloud Gate Credentials Command writes configuration information into a config file in the Dock Cube Directory in the Home Directory By default, if you re-run this command for a different cluster, will update the conflict file with the credentials from the new cluster. You only need to perform this configuration process once per cluster in your cloud shell.

$gcloud container clusters
get-credentials w-sandbox \
— zone oregon \

Can you figure out why the command is Gcloud to get credentials rather than kubectl to get credentials? It’s because the kubectl Command requires credentials to work at all. The G Cloud command is how authorized users interact with G C P from the command line. The G cloud get credentials command gives you the credentials you need to connect with a G K E cluster if you’re authorized to do so. In general, QC TL is a tool for administrating the internal state of an existing cluster, But kubectl can’t create new clusters or change the shape of existing clusters. For that, you need the G K E control plane, which is the G Cloud Command and the G C P console is your interface is too.

The Kubectl Syntax

Its syntax has several parts; command, type, name, and optional flags. The command specifies what you intend to do such as to get, deceive, log, and execute while others allow you to change the clusters config. The type tells the type of object you want to perform the command action on like pod, nodes, and others. The name is for the object name that you intend to perform an action and if you don’t put a name, it will return all the pods. You can use flags to check more information in a wider format. Kubectl is used to create k8s objects, view, work, and config.

Introspection

It is the act of gathering information concerning the services, containers, pods, and other engines running within the cluster after running the kubectl command. You can use Kubectl to

get (kubectl get pods)describe (kubectl describe my-pod-d )exec (kubectl exec my-pod-d)

logs to know what happens inside the pod; it’s useful when you want to know better info about the containers.
PendingRunning (starting, restarting or running)SucceededFailedUnknownCrashLoopBackoff (if the pod is not configured correctly)

Pod Phases (Describe)

NameNamespaceNode nameLabelsStatusIP address etc

Exec

  1. To troubleshoot connectivity and you can run a single command with the result in your cloud shell. From here you can access the inside the pod for work.

You can perform arguments in the container with the above processes. You can use the -c to check the specific container.

Don’t be alarmed, after understanding the necessary terms, then the solving is ot a problem, although I plan to do hands-on learning after all the theroertical part is completed. 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