Coder Social home page Coder Social logo

bukola-testimony / deploying-a-simple-personal-website-docker-image-on-google-kubernetes-engine-gke-clusters. Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 6.11 MB

Deploying a simple personal website docker-image on google kubernetes engine GKE clusters.

HTML 66.76% Dockerfile 0.62% CSS 32.62%
docker docker-compose docker-container docker-image dockerfile dockerhub gke-cluster google-cloud google-cloud-platform kubectl kubernetes kubernetes-cluster kubernetes-deployment kubernetes-setup nginx nginx-docker pod

deploying-a-simple-personal-website-docker-image-on-google-kubernetes-engine-gke-clusters.'s Introduction

Google-kubernetes-mini-project

Google-kubernetes-mini-project



OVERVIEW

CREATING A WEB-DEPLOYMENT USING A DOCKER IMAGE ON GOOGLE KUBERNETES ENGINE (GKE).

Kubernetes is an open-source platform that helps you orchestrate and manage your container infrastructure on-premises or in the cloud.

It automates the deployment, scaling, load balancing, logging, monitoring, and other management features of containerized applications. These are the features that are characteristic of typical platform-as-a-service solutions. Kubernetes also facilitates the features of infrastructure-as-a-service, such as allowing a wide range of user preferences and configuration flexibility.

Google Kubernetes Engine (GKE) is a managed Kubernetes service on Google infrastructure. GKE helps you to deploy, manage, and scale Kubernetes environments for your containerized applications on Google Cloud.

In this write up, you are going to learn how to:

  • Build a simple personal website and package it in a container image based off of nginx.
  • publish the image on the docker registry
  • create a deployment with the website image.
  • Make it is publicly available.



Process

  • Build a simple personal website and package it in a container image based off of nginx.
  • publish the image on the docker registry
  • Log in to your Google Cloud Platform account and navigate to the Kubernetes Engine in the left navigation panel.
  • Click “Create cluster” and choose the “standard” option.
  • Name your cluster and select your zone.
  • Leave the other default configurations and scroll down. Click “Create” to create the cluster. This takes a few minutes for the cluster to be provisioned.
  • Once the cluster is running, connect to it using the Google Cloud Shell.
  • Now create your deployment using the web image
  • Expose the deployment using a load balancer and a port.
  • Finally, copy the external IP to your browser. If you are able to view your website, then your deployment was successful.


Links to files


Build a simple personal website and package it in a container image based off of nginx.

For this project I already have a simple personal website pushed to github. If you have a website pushed to github, simply clone it into your local work area. in your terminal, cd into your cloned project and create a dockerfile

touch Dockerfile
nano Dockerfile

Place the following code into the dockerfile, save and close:

FROM nginx:alpine

# set work directory
WORKDIR  /usr/share/nginx/html

# copy files into html directory
COPY  . .

# expose port 80 on the container
EXPOSE 80

To build the image, run the following commands on your terminal:

docker build -t portfolio . 
# Replace <portfolio> with any name of your choice. 
# Also include the dot at the end of the command

docker image ls
# To check your image 
 

You can run the image in a detached mode and give it a port using the following command:

docker run -dit -p 8000:80 portfolio
# Note: check your localhost:8000 to view your image.
 

To push your image to Dockerhub.com. First rename the image and login to your dockerhub. Run the following commands:

docker tag portfolio bukola01/portfolio
# Note: replace <bukola01> with your dockerhub username
docker login 
# Note this will prompt you to enter your username and password
docker push bukola01/portfolio
 

The web image has been pushed to Dockerhub.com

To pull the image at anytime, run the following command:

docker pull bukola01/portfolio


CREATE A DEPLOYMENT ON GOOGLE KUBERNETES ENGINE (GKE) WITH THE WEB IMAGE.

step one

Log in to your Google Cloud Platform account and navigate to the Kubernetes Engine in the left navigation panel. Note: if this is your first time, you will be prompted to enable the Google kubernetes Engine API. Click on "OK" and wait for the API to be enabled.


Google-kubernetes-mini-project



step two

Click “Create cluster” and choose the “standard” option.


Google-kubernetes-mini-project


Google-kubernetes-mini-project



step three

Name your cluster and select your zone. Click “Create” to create the cluster. This takes a few minutes for the cluster to be provisioned.


Google-kubernetes-mini-project



step four

Once the cluster is running, connect to it using the Google Cloud Shell


Google-kubernetes-mini-project


Google-kubernetes-mini-project



step five

click on "run in cloud shell" and allow the environment to provision.

Google-kubernetes-mini-project


Google-kubernetes-mini-project



step six

Enter the cloud authentication code already placed in your cloud shell area. This may ask for authentication, click ok. Then configure your project ID. To do that, Follow the guide in the screenshots below.

Google-kubernetes-mini-project


Google-kubernetes-mini-project


Google-kubernetes-mini-project



step seven

Now create your deployment and expose it using the following commands.

kubectl create deployment myweb --image=bukola01/portfolio
kubectl get deployment
kubectl expose deployment myweb --type=LoadBalancer --port=80
kubectl get service

Google-kubernetes-mini-project



step eight

Finally, copy the external IP only (without the port) to your browser. If are able to view your website, then your deployment was successful.

Google-kubernetes-mini-project

Congratulations!

Author

deploying-a-simple-personal-website-docker-image-on-google-kubernetes-engine-gke-clusters.'s People

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.