Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.
Source: https://kubernetes.io/
Follow these 10 steps to get an instance of loklak running on Google Cloud platform using Kubernetes.
Note: The document uses predefined names for various properties like project ID and docker image name to avoid confusion. You may want to change them when needed.
Visit https://cloud.google.com/free/ and follow on-screen instructions to create an account and get the free trial.
Create a new project with desired name and ID.
Go to https://console.cloud.google.com/kubernetes/list and wait for the container engine to get ready. You may need to select the project from the project section in the top-left corner.
In the top-right panel, click the shell button.
You'll be greeted by an online console.
$ git clone https://github.com/loklak/loklak_server.git
$ cd loklak_server/
$ docker build -t gcr.io/singhpratyush-loklak/loklak:v1 .
$ gcloud docker -- push gcr.io/singhpratyush-loklak/loklak:v1
This makes our cloud registry ready. Let us create a Kubernetes cluster where we can deploy this.
gcloud
provides easy to use interface for creating clusters. Let us take a look at the properties that we can configure while creating a cluster.
Argument | Function | Allowable Values |
---|---|---|
--num-nodes |
Number of nodes in the cluster. | A natural number |
--machine-type |
Type of each machine in the cluster. | f1-micro g1-small n1-standard-{1,2,4,8} n1-highmem-{2,4,8} n1-highcpu-{2,4,8} |
--zone |
Zone where nodes would be located. | See Compute Engine Docs |
For this example, let us create a cluster with following command -
$ gcloud container clusters create loklak-cluster --num-nodes 3 --machine-type n1-standard-1 --zone us-central1-c
This will take a few minutes to complete. After done, you can see a new cluster active on your console.
$ kubectl run loklak --image=gcr.io/singhpratyush-loklak/loklak:v1 --port=80
deployment "loklak" created
You can see a list of deployments by running the following commands -
$ kubectl get deployments
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
loklak 1 1 1 1 2m
With the server now deployed internally on Google Cloud Platform, we need to expose it to the Internet. For this, we use the following command -
$ kubectl expose deployment loklak --type=LoadBalancer
service "loklak" exposed
Now, the platform will assign an external IP to the application. This may take some time. Run the following command to see the assigned external IP -
$ kubectl get services
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes 10.79.240.1 <none> 443/TCP 10m
loklak 10.79.248.1 104.154.24.48 80:30287/TCP 1m
On a browser, visit the deployment using the external IP (http://104.154.24.48/ in this case).