k1s
                                
                                
                                
                                    k1s copied to clipboard
                            
                            
                            
                        Learn how to use Kubernetes
k1s
there is only one letter here from k to s which is E
   
   
Introduction
Kubernetes is an awesome platform, and we want to have fun with it here with this project.
In this repository we've created an example Golang server and then created pod, service etc. for it.
The hello-server is a simple HTTP server that we want to deploy on the cloud.
It must be replicated, so everyone can get their hello even in the peak time.
Step by Step
At the beginning you need an up and running Kubernetes cluster.
Mircok8s is an awesome platform if you don't know where to start.
(For having kubectl at your hand with Mircok8s check this)
First, create and switch to your desired namespace.
kubectl create namespace k1s
# kcd is an alias for kubectl context switch
alias kcd='kubectl config set-context $(kubectl config current-context) --namespace'
kcd k1s
Then follow these instructions to have your hello-server up and running.
The hello-server application requires a config to work. Possible options are providing config through a config.yaml file, environment variables, or stick to the default config.
Passing config files and environment variables is through a ConfigMap. To test each way, comment out the other one's way of loading in k1s-deployment.yaml
- 
Create ConfigMap
kubectl apply -f k1s-config-map.yaml kubectl get configmaps - 
Create Deployment (kubernetes needs gcr and docker-hub so have proxy at your pocket)
kubectl apply -f k1s-deployment.yaml kubectl get deployment kubectl get podTo visualize the usage of
health-checkyou can use/dieendpoint to makehealth-checkfail, and then check what happened withkubectl get events --watchto watch the whole process as it happens. - 
Create Service (make sure you did
microk8s enable dns)kubectl apply -f k1s-svc.yaml kubectl get svck1sservice is used to associate a name fork1s-deploymentpod's IP addresses inside cluster. You can create a pod and access k1s through it.kubectl run alpine -ti --image alpine --rm --restart=Never -- sh > apk add curl > curl htpp://k1s:1378By running this command several times, you can see that this service is working also as a simple
Load Balancer. Note: make sureDNSservice is running for k8s. - 
Create Ingress
kubectl apply -f k1s-ingress.yamlIngress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster.
It simply provides a way to access your pods from Internet by specifying which requests are destined for your
service. For ingress to work you must first add a ingress controller. AlsoDNSservice must be enabled