Skip to content

Instantly share code, notes, and snippets.

@danrjohnson
Last active September 20, 2018 00:41
Show Gist options
  • Save danrjohnson/74b11bc58271ceab99b37cd4596bb7d7 to your computer and use it in GitHub Desktop.
Save danrjohnson/74b11bc58271ceab99b37cd4596bb7d7 to your computer and use it in GitHub Desktop.
Kubernetes Training Materials
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: gethostname
spec:
replicas: 1
template:
metadata:
labels:
app: gethostname
spec:
containers:
- name: gethostname
image: danrjohnson/gethostname:latest
ports:
- containerPort: 8080
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
labels:
app: nginx
spec:
replicas: 5
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
name: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: nginx
labels:
app: nginx
spec:
# modify replicas according to your case
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
apiVersion: v1
kind: Service
metadata:
name: gethostnames
labels:
app: gethostname
spec:
# if your cluster supports it, uncomment the following to automatically create
# an external load-balanced IP for the frontend service.
type: LoadBalancer
ports:
# the port that this service should serve on
- port: 8080
selector:
app: gethostname
kind: Service
apiVersion: v1
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
type: LoadBalancer
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::DEFAULT_SERVER_URL.replace('https://vagrantcloud.com')
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-18.04"
config.vm.network "forwarded_port", guest: 8443, host: 8443
config.vm.network "forwarded_port", guest: 8001, host: 8001
config.vm.network "forwarded_port", guest: 30000, host: 30000
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo touch /etc/apt/sources.list.d/kubernetes.list
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
apt-get update
apt-get install -y docker-ce kubectl
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.28.2/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
echo "alias minikubestart='sudo minikube start --vm-driver=none'" >> /home/vagrant/.bashrc
minikube start --vm-driver=none
mv /root/.kube /home/vagrant/.kube # this will write over any previous configuration
chown -R vagrant /home/vagrant/.kube
chgrp -R vagrant /home/vagrant/.kube
mv /root/.minikube /home/vagrant/.minikube # this will write over any previous configuration
chown -R vagrant /home/vagrant/.minikube
chgrp -R vagrant /home/vagrant/.minikube
sed -i 's@root@home\/vagrant@' /home/vagrant/.kube/config
SHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment