Mini Kube Demo application container
130
Mini Kube Demoā is a repository holding files and instructions required for a simple technical demo a simple Golangā web application deployed in loadbalanced fashion on Kubernetesā (with use of MiniKubeā ).
The demo requires following software to be installed on the system:
Additionally, following software could be installed for development of the demo:
Installing of the required software is not in the scope of this demo, therefore the users should handle the installation themselves, accoringly to the documentation from respective projects, or seek technical help.
Mini Kube Demo requires an access to a system terminal (ie. Terminal.app on MacOS Intel/AppleSilicon) and some terminal proficiency.
Follow the steps below in the terminal.
Start a Mini Kube cluster
$ minikube start
š minikube v1.25.2 on Darwin 12.2.1 (arm64)
(... stripped ...)
š Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
$
Clone the Mini Kube Demo repository and enter to the folder
$ git clone [email protected]:bartekrutkowski/mini-kube-demo.git && cd mini-kube-demo
Cloning into 'mini-kube-demo'...
(... stripped ...)
$
Deploy the Deployment, Service and Ingress resources on the Mini Kube cluster using kubectl and the mini-kube-demo-deployment.yaml file
$ kubectl apply -f mini-kube-demo-deployment.yaml
namespace/hello-world created
deployment.apps/hello-world created
service/hello-world created
ingress.networking.k8s.io/hello-world created
$
Verify the deployment with kubectl
$ kubectl -n hello-world get all
NAME READY STATUS RESTARTS AGE
pod/hello-world-697cff6b6c-dtb69 1/1 Running 0 85s
pod/hello-world-697cff6b6c-hkr8w 1/1 Running 0 85s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/hello-world LoadBalancer 10.101.83.79 <pending> 8080:30480/TCP 85s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/hello-world 2/2 2 2 85s
NAME DESIRED CURRENT READY AGE
replicaset.apps/hello-world-697cff6b6c 2 2 2 85s
$
Launch Mini Kube Tunnelā service (you may be asked for your operating system password)
$ minikube tunnel
ā
Tunnel successfully started
š NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ...
š Starting tunnel for service hello-world.
ā The service/ingress hello-world requires privileged ports to be exposed: [80 443]
š sudo permission will be asked for it.
š Starting tunnel for service hello-world.
Password:
Note that minikube tunnel command wont return to the command prompt and needs to run until the end of the demo, otherwise there will be no connectivity to the application running on the cluster.
Verify that the application is running in loadbalanced fashion with curl
$ for i in $(seq 0 10); do curl http://localhost:8080/; done
Hello world from fVoV2t
Hello world from fVoV2t
Hello world from JppA1h
Hello world from 6LvgZD
Hello world from JppA1h
Hello world from 6LvgZD
Hello world from JppA1h
Hello world from JppA1h
Hello world from EVewSe
Hello world from EVewSe
Hello world from fVoV2t
$
Note, how the ID string of the pod changes randomly, depending on which pod out of the default 4 replicas serves the HTTP request.
Alternatively you can open a web browser window and paste the http://localhost:8080/ url to the address bar, refreshing few times - you should be able to observe the same changing names.
After experimenting with the demo, follow the steps below in the terminal.
Stop the minikube tunnel with ^C (CTL + C)
ā
Tunnel successfully started
š NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ...
š Starting tunnel for service hello-world.
ā The service/ingress hello-world requires privileged ports to be exposed: [80 443]
š sudo permission will be asked for it.
š Starting tunnel for service hello-world.
Password:
^Cā Stopped tunnel for service hello-world.
ā Stopped tunnel for service hello-world.
$
Delete the resources from the Mini Kube cluster
$ kubectl delete -f mini-kube-demo-deployment.yaml
namespace "hello-world" deleted
deployment.apps "hello-world" deleted
service "hello-world" deleted
ingress.networking.k8s.io "hello-world" deleted
$
Verify with kubectl that the resources are deleted properly
$ kubectl -n hello-world get all
No resources found in hello-world namespace.
$
Delete the MiniKube cluster with minikube
$ minikube delete
š„ Deleting "minikube" in docker ...
š„ Deleting container "minikube" ...
š„ Removing /Users/r/.minikube/machines/minikube ...
š Removed all traces of the "minikube" cluster.
$
And that's it, the demo is concluded, the environment is cleaned up.
If the Docker image from the public repository published on Docker Hubā doesn't work on the testing machine due to operating system or architecture differences, one can build it's own Docker image with docker command, assuming we have the repository cloned already from the above instructions.
$ cd hello-world && docker build . -q -t mini-kube-demo:latest
sha256:719f885a0c36e2f5979497f88ea604bde2d1cf623f075f2030444ba9e81bf933
$
The image built this way needs to be then properly tagged and pushed to a container registry of choice. Once that's done, the mini-kube-demo-deployment.yaml file needs to be edited where the container image is set.
(... stripped ...)
27 spec:
28 containers:
29 - name: hello-world
30 image: bartekrutkowski/mini-kube-demo:latest
31 imagePullPolicy: Always
32 ports:
(... stripped ...)
The source code for this Docker container and the application in it can be found on GitHubā .
While I retain the author'sā rights for the application, the entire repository and all its artifacts are relased under the BSD 3-Clause licenseā and is free to use.
Content type
Image
Digest
Size
3.3 MB
Last updated
over 4 years ago
docker pull bartekrutkowski/mini-kube-demo