Download multipass at https://multipass.run/
Create an Ubuntu 18.04 VM
multipass launch --name k8s --mem 4g --disk 40g --cpus 3
Start it
multipass start k8s
Shell into it
multipass shell k8s
Install minik8s
sudo snap install microk8s --classic
Start minik8s
sudo microk8s.start
Enable DNS
sudo microk8s.enable dns
Enable Dashboard
sudo microk8s.enable dashboard
Get a token
token=$(microk8s.kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)
Show the token
sudo microk8s.kubectl -n kube-system describe secret $token
Copy and paste this somewhere special on your host machine (~/.mytoken)
Create a dashboard user yaml file
nano dashboard-adminuser.yaml
Paste stuff into the yaml file
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kube-system
Install kubectl
sudo snap install kubectl --classic
Edit the dashboard service
kubectl -n kube-system edit service kubernetes-dashboard
Replace ClusterIP
with NodePort
at the type
key:
apiVersion: v1
...
name: kubernetes-dashboard
namespace: kube-system
resourceVersion: "343478"
selfLink: /api/v1/namespaces/kube-system/services/kubernetes-dashboard-head
uid: 8e48f478-993d-11e7-87e0-901b0e532516
spec:
clusterIP: 10.100.124.90
externalTrafficPolicy: Cluster
ports:
- port: 443
protocol: TCP
targetPort: 8443
selector:
k8s-app: kubernetes-dashboard
sessionAffinity: None
type: ClusterIP <----- REPLACE THAT WITH NodePort
status:
loadBalancer: {}
Check where the dashboard is exposed
kubectl -n kube-system get service kubernetes-dashboard
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes-dashboard 10.100.124.90 <nodes> 443:31707/TCP 21h
Write down that port. Above it's 31707.
Get out of the shell
exit
Install kubectl locally
brew install kubectl
Get the kubeconfig into the local environment
multipass exec microk8s-vm -- /snap/bin/microk8s.config > kubeconfig
Edit bash profile to use the kubeconfig forever and ever
nano ~./bash_profile
Add export to the file
export KUBECONFIG=~/.kubeconfig
Load the file
source ~/.bash_profile
Look at the cluster
kubectl cluster-info
View the dashboard by going to a browser and loading https://192.168.64.2:30251/#!/login
Login using your token in ~/.my-token
Ok, now let's deploy the hipster app
git clone git@github.com:GoogleCloudPlatform/microservices-demo.git
Now we can deploy the hipster app on K8s
kubectl apply -f microservices-demo/release/kubernetes-manifests.yaml
Ok! Finally let's get the port we can browse on our host machine:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
frontend-external LoadBalancer 10.152.183.25 <pending> 80:32675/TCP 21m
Now you can open the hipster app on port 32675 (of the cluster-info IP address)