DEV Community

Cover image for How I did DigitalOcean's Kubernetes Challenge
Prajal Sharma
Prajal Sharma

Posted on

How I did DigitalOcean's Kubernetes Challenge

About Kubernetes and Clusters

Kubernetes (also known as k8s or “kube”) is an open source container orchestration platform that automates many of the manual processes involved in deploying, managing, and scaling containerized applications.

You can cluster together groups of hosts running containers, and Kubernetes helps you easily and efficiently manage those clusters.

Kubernetes clusters can span hosts across on-premise, public, private, or hybrid clouds. For this reason, Kubernetes is an ideal platform for hosting cloud-native applications that require rapid scaling.

About DigitalOcean

DigitalOcean simplifies cloud computing so developers and businesses can spend more time building software that changes the world. With its mission-critical infrastructure and fully managed offerings, DigitalOcean helps developers, startups and small and medium-sized businesses (SMBs) rapidly build, deploy and scale applications to accelerate innovation and increase productivity and agility. DigitalOcean combines the power of simplicity, community, open source, and customer support, so customers can spend less time managing their infrastructure and more time building innovative applications that drive business growth.

About this Challenge

Whether you’re new to Kubernetes, or you have been running production clusters for years, this challenge will give you an opportunity to level-up your Kubernetes skill set before the end of 2021. This challenge is for everyone from beginner to export on K8s. There are four different challenges.

Choose your Challenge

New to Kubernetes? Try one of these challenges. You’ll get $60 in DigitalOcean credits for your project.

  • Deploy an internal container registry Kubernetes does not provide an internal container registry but it is often useful to add one. There are many projects which enable you to deploy an internal container registry, such as Harbour or Trow.
  • Deploy a log monitoring system So your applications produce logs. Lots of logs. How are you supposed to analyze them? A common solution is to aggregate and analyze them using the ELK stack, alongside fluentd or fluentbit.
  • Deploy a scalable SQL database cluster When deploying a database on Kubernetes, you have to make it redundant and scalable. You can rely on database management operators like KubeDB or database-specific solutions like Kubegres for PostgreSQL or the MySQL Operator for MySQL.
  • Deploy scalable NoSQL database cluster When it comes to cloud native, using No-SQL solutions has its advantages. You can deploy a cluster of MongoDB, Cassandra, or CouchDB instances to explore how to run a NoSQL database in Kubernetes.

I chose Deploy a scalable NoSQL database cluster in kubernetes.

My Github Repo

Here is the link of github repository in which I did the DigitalOcean Kubernetes Challenge

https://github.com/prajalsharma/mongodb-kubernetes-cluster

Deployment Guide

Prerequisites

Step 1 : Creating a Kubernetes Cluster on DigitalOcean

  • Create a new kubernetes cluster in your project segment by clicking on the Kubernetes button in Create dropdown button on the top right.

Image description

  • Choose and fill in the following fields (choose wisely as they will affect your money consumption etc)
  • For my project I chose , DataCenter:Bangalore , Nodeplan:10$/month per node , Node Count : 1,etc. (You can choose the name for your cluster as well)
  • Click on 'Create Cluster'.
  • Wait for a few minutes for the cluster to be created .

Image description

Step 2 : Connecting to the cluster

  • After node Creation,scroll down and press "Overview"
  • Press "Get started!"
  • In "connecting to kubernetes" , copy the command and paste it in terminal. (make sure kubectl and doctl are installed as it won't work if they aren't installed) Image description
  • Run the copied command on your terminal.
  • After it runs it will look like this on windows , if your result is same then you've connected your device with the Kubernetes Cluster. Image description

Step 3 : Deploy a MongoDB Cluster

  • Clone this repository by running the command below on your terminal
git clone https://github.com/prajalsharma/mongodb-kubernetes-cluster.git
Enter fullscreen mode Exit fullscreen mode
  • Go to the repo directory on you local machine through terminal.
  • Run kubectl apply -f to to deploy the MongoDB Cluster.
  • Run kubectl get all to get the status of deployment.
  • The result will look like image below , that means you've comleted this step successfully.

Image description

Step 4 : Verify the Deployment

  • Run kubectl exec deployment/mongo-client -it -- /bin/bash to connect to the MongoDB cluster.
  • The Command Prompt should change to root@mongo-client-xxxx
  • Run mongo --host mongo-nodeport-svc --port 27017 -u <username> -p <password> where username and password are the decoded values for the base64 credentials you entered in mongodb-secrets.yaml file.
  • You should see the mongoDB info and prompt for mongo commands.

Image description

The End

Congratulations you've made it till the end of this repo and now the terminal will show this after show dbs command.

Image description
You have successfully deployed a NoSQL Database on Kubernetes.

Miscellaneous

I have used Windows 10 for this , so people using other OS might get some errors. It was my first time using Kubernetes on DigitalOcean . Thanks to Organisers and everyone , got to learn a lot .

Top comments (0)