Skip to content

Instantly share code, notes, and snippets.

@WillMoggridge
Last active November 8, 2017 18:07
Show Gist options
  • Save WillMoggridge/1e33ae014e3b0f9d692ebd77f0584c1a to your computer and use it in GitHub Desktop.
Save WillMoggridge/1e33ae014e3b0f9d692ebd77f0584c1a to your computer and use it in GitHub Desktop.
design.ubuntu.localhost - Kubernetes test config

Install Minikube

Visit the official information for installing Minikube: https://kubernetes.io/docs/tasks/tools/install-minikube/

You need to install Virtualbox, Minikube, and kubectl.

Once installed, run:

minikube start

This will start a VM in the background and will keep running. When you don't want it, you can run minikube stop.

Enable the dashboard:

minikube addons enable dashboard
minikube dashboard

Deploy the local site

Download the .yaml file and save somewhere.

Either upload the file with the dashbard - there is a "Create" button at the top right. Or use the command line:

kubectl config use-context minikube
kubectl apply -f design-ubuntu-localhost.yaml

Wait a few minutes. You can view the status in the dashboard with minikube dashboard. You can test if it is up with:

curl -I -H 'Host: design.ubuntu.localhost' `minikube ip`

Viewing the site

Add the minikube ip output to your /etc/hosts file to view it in a web browser. In the hosts file:

[IP FROM COMMAND] design.ubuntu.localhost
# My entry:
# 192.168.99.100 design.ubuntu.localhost

Then visit http://design.ubuntu.localhost

---
kind: Service
apiVersion: v1
metadata:
name: design-ubuntu-localhost
spec:
selector:
app: design.ubuntu.localhost
ports:
- name: http
protocol: TCP
port: 80
targetPort: http
---
kind: Deployment
apiVersion: apps/v1beta1
metadata:
name: design-ubuntu-localhost
spec:
replicas: 2
template:
metadata:
labels:
app: design.ubuntu.localhost
spec:
containers:
- name: design-ubuntu-localhost
image: canonicalwebteam/design.ubuntu.com
imagePullPolicy: Always
ports:
- name: http
containerPort: 80
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
periodSeconds: 5
---
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: design-ubuntu-localhost
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- host: design.ubuntu.localhost
http:
paths:
- path: /
backend:
serviceName: design-ubuntu-localhost
servicePort: 80
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment