Skip to content

Instantly share code, notes, and snippets.

@bassam
Last active April 23, 2019 10:14
Show Gist options
  • Save bassam/46d8b23aa7ff20ebfa38c22d2d3e5549 to your computer and use it in GitHub Desktop.
Save bassam/46d8b23aa7ff20ebfa38c22d2d3e5549 to your computer and use it in GitHub Desktop.
KubeCon Demo

setup

Startup a 3 node Kuberentes cluster.

Run this in a shell to see the whats happening in the cluster:

watch -t -n1 'kubectl get pods -n rook  -o wide && echo && echo && kubectl get pods -o wide && echo && echo && kubectl get pvc'

demo

First create the operator:

kubectl create -f operator.yaml

Next create the cluster:

kubectl create -f cluster.yaml
```

Next create the pool and storageclass:
```
export MONS=$(kubectl -n rook get pod mon0 mon1 mon2 -o json|jq ".items[].status.podIP"|tr -d "\""|sed -e 's/$/:6790/'|paste -s -d, -) && sed 's#INSERT_HERE#'$MONS'#' pool.yaml | kubectl create -f -
```

Run the wordpress app:
```
kubectl create -f wordpress.yaml
```

Get the ip address of the wordpress pod and port:
```
kubectl get pods -o wide
kubectl get svc wordpress
```

# client

if you want to run the rook client:
```
kubectl create -f rook-client.yaml
kubectl -n rook exec rook-client -it bash
```

# cleanup

to cleanup run the following:
```
kubectl delete -f wordpress.yaml
kubectl delete deployment rook-operator
kubectl delete thirdpartyresources rookcluster.rook.io rookpool.rook.io
kubectl delete storageclass rook-block
kubectl delete secret rook-rbd-user
kubectl delete namespace rook
kubectl delete -f rook-client.yaml
```
apiVersion: rook.io/v1beta1
kind: Rookcluster
metadata:
name: rook
spec:
namespace: rook
version: latest
dataDirHostPath:
useAllDevices: false
deviceFilter:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: rook-operator
spec:
replicas: 1
template:
metadata:
labels:
name: rook-operator
spec:
containers:
- name: rook-operator
image: quay.io/rook/rook-operator
env:
- name: ROOK_OPERATOR_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
apiVersion: rook.io/v1beta1
kind: Rookpool
metadata:
name: rook-replicapool
spec:
name: replicapool
namespace: rook
replication:
count: 1
---
apiVersion: storage.k8s.io/v1beta1
kind: StorageClass
metadata:
name: rook-block
namespace: rook
provisioner: kubernetes.io/rbd
parameters:
monitors: INSERT_HERE
adminId: admin
adminSecretName: rook-admin
adminSecretNamespace: rook
pool: replicapool
userId: rook-rbd-user
userSecretName: rook-rbd-user
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pv-claim
annotations:
volume.beta.kubernetes.io/storage-class: rook-block
labels:
app: wordpress
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
---
apiVersion: v1
kind: Service
metadata:
name: wordpress-mysql
labels:
app: wordpress
spec:
ports:
- port: 3306
selector:
app: wordpress
tier: mysql
clusterIP: None
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: wordpress-mysql
labels:
app: wordpress
spec:
strategy:
type: Recreate
template:
metadata:
labels:
app: wordpress
tier: mysql
spec:
containers:
- image: mysql:5.6
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
value: changeme
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pv-claim
---
apiVersion: v1
kind: Service
metadata:
name: wordpress
labels:
app: wordpress
spec:
ports:
- port: 80
selector:
app: wordpress
tier: frontend
type: NodePort
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: wp-pv-claim
annotations:
volume.beta.kubernetes.io/storage-class: rook-block
labels:
app: wordpress
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: wordpress
labels:
app: wordpress
spec:
strategy:
type: Recreate
template:
metadata:
labels:
app: wordpress
tier: frontend
spec:
containers:
- image: wordpress:4.6.1-apache
name: wordpress
env:
- name: WORDPRESS_DB_HOST
value: wordpress-mysql
- name: WORDPRESS_DB_PASSWORD
value: changeme
ports:
- containerPort: 80
name: wordpress
volumeMounts:
- name: wordpress-persistent-storage
mountPath: /var/www/html
volumes:
- name: wordpress-persistent-storage
persistentVolumeClaim:
claimName: wp-pv-claim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment