FOTC
  • Products
    • Google Workspace
    • Google Cloud
  • Services
    • Cloud engineering as a service
    • Cloud Infrastructure Strategy Roadmap
    • Google AI
    • Landing Zone
    • Security audit
    • Technical support
  • About us
  • Startups
  • Resources
    • Case studies
    • Blog
    • Partner programme
  • Careers
Contact
ro pl hu en
  • Privacy policy

Kubernetes 101 – a brief tutorial

EN » Blog » Kubernetes 101 – a brief tutorial

Beata Socha

21 June 2023
Kubernetes 101 – a brief tutorial

Kubernetes on Google Cloud – tutorial

In this article you will learn the basics of Kubernetes cluster orchestration system on Google Cloud. In a few simple steps we will walk you through creating a project, including setting the region, creating a cluster and deploying an application to it. Let’s get started.

The first step is to access the Google Cloud Console: https://console.cloud.google.com/.

Create a project

Create a new project (click on the project name next to “Google Cloud” in the top left corner).

Google Cloud Platform - tworzenie nowego projektu
Google Cloud – creating a new project

Enter the project name and click Create.

Google Cloud Platform - tworzenie nowego projektu

To view the list of projects again (button next to “Google Cloud”), you will obtain the project ID. You will need it for the following steps.

Google Cloud Platform - tworzenie nowego projektu

Cloud Shell

Open Cloud Shell (top right corner).

Kubernetes tutorial - cloudshell
Kubernetes tutorial – Cloud Shell

Use the following command to set the project you will be working on:

gcloud config set project k8s-demo-281313

Note that in the command, you should enter your own project ID, which may differ from the example provided.

Kubernetes tutorial - ustawienia projektu
Kubernetes tutorial – project settings

Set the region

Next, set the region where you want to deploy the application:

gcloud config set compute/zone europe-west3-c

Check Google Cloud list of regions.

Kubernetes tutorial - ustawienie regionu
Kubernetes tutorial – setting the region

Create a cluster

Create a cluster using the command:

gcloud container clusters create my-cluster--num-nodes=1

The –num-nodes flag allows you to specify the number of nodes (physical or virtual machines) in the cluster. Read more about the flag.

This operation may take a few minutes.

After the operation is completed, you will receive a table in Cloudshell that shows the cluster parameters.

Kubernetes tutorial - parametry klastra
Kubernetes tutorial – cluster parameters

Now use the command:

gcloud container clusters get-credentials my-cluster

This command updates the kubeconfig file with the appropriate references and information for further work with the cluster.

Kubernetes tutorial - aktualizacja pliku o referencje i informacje
Kubernetes tutorial – updating the file with references and information

Deploy your app to the cluster

To deploy an application to the cluster, use the following command:

kubectl create deployment hello-server --image=gcr.io/google-samples/hello-app:1.0

The –image flag indicates the link to the containerized application in the Container Registry (GCR). The Container Registry service allows you to store containerized application images. Read more about the GCR feature. 

Here is the source code of the hello-app we are deploying.

You can deploy your application by specifying the containerized image from the Container Registry.

Kubernetes tutorial - contaner registry
Kubernetes tutorial – container registry

Expose the app

Now you need to expose the application. For this purpose, use the command:

kubectl expose deployment hello-server --type LoadBalancer \
--port 80 --target-port 8080

You can read more about the “kubectl” command.

The flag

--type

indicates the type of deployment (ClusterIP, NodePort, LoadBalancer, or ExternalName). In this case, we are creating a LoadBalancer, which will make the application accessible over the internet.

The flag:

--port

indicates specifies the port on which the application will be served.

 The flag:

--target-port

specifies the port in the container to which the service should direct traffic.

Next, enter the command:

kubectl get service hello-server

This will provide you with the public IP of the cluster where you deployed the application.

Kubernetes tutorial - IP klastra

Here is the result:

Kubernetes tutorial - hello world

Remove the cluster

To remove the cluster and undo the deployment, use the commands:

kubectl delete service hello-server
gcloud container clusters delete my-cluster
Kubernetes tutorial - usuniecie klastra
Kubernetes tutorial – deleting the cluster

And that’s all for Kubernetes 101! Hope you enjoyed creating your first cluster and deploying your app into it. Good luck!

Kubernetes on Google Cloud – tutorial
Create a project
Cloud Shell
Set the region
Create a cluster
Deploy your app to the cluster
Expose the app
Remove the cluster

Beata Socha

Writer, journalist, storyteller with 15 years' experience in creating high quality copy. At FOTC, Beata works as Content Manager.

Services
  • Cloud Infrastructure Strategy Roadmap
  • Landing Zone
  • Training
Products
  • Google Workspace
  • Google Cloud
  • Google Workspace for Education
Industry
  • Education
  • Gaming
  • Government
  • Healthcare
  • Retail
  • Small and medium businesses
Knowledge
  • Blog
  • Case Studies
  • NIS2 directive
Company
  • About us
  • Career
  • Contact
  • Partner programme
  • Google Workspace Support
  • Privacy Policy
  • Regulations
Copyright © 2014 – 2024 Fly On The Cloud sp. z o.o. KRS: 0000500884, NIP: 8971797086, REGON: 022370270