Skip to content

Instantly share code, notes, and snippets.

@Seth-Karlo
Last active Oct 23, 2018
Embed
What would you like to do?
https://gist.github.com/Seth-Karlo/38055c64d9f560b9a411e34de8a5da00
## Install Kubectl for Mac:
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.6.6/bin/darwin/amd64/kubectl
chmod +x kubectl
mv kubectl /usr/local/bin
## Install Kubectl for Linux:
curl -O https://storage.googleapis.com/kubernetes-release/release/v1.6.6/bin/linux/amd64/kubectl
chmod +x kubectl
mv kubectl /usr/local/bin
## Install kops for Mac:
curl -LO https://github.com/kubernetes/kops/releases/download/1.6.2/kops-darwin-amd64
chmod +x kops-darwin-amd64
mv kops-darwin-amd64 /usr/local/bin/kops
## Install kops for Linux:
curl -Lo https://github.com/kubernetes/kops/releases/download/1.6.2/kops-linux-amd64
chmod +x kops-linux-amd64
mv kops-linux-amd64 /usr/local/bin/kops
## Clone the workshop:
git clone git@github.com:Seth-Karlo/intro-to-kubernetes-workshop.git
## Export the variables needed:
export KOPS_STATE_STORE=s3://devopsdays-ams
export MYNAME=user1
export NAME=${MYNAME}.sbp-demo.com
export AWS_ACCESS_KEY_ID=$YourID
export AWS_SECRET_ACCESS_KEY=$yourkey
## Build your cluster:
kops create cluster --zones eu-west-1a --node-size t2.medium --master-size t2.medium $NAME && kops update cluster ${NAME} --yes
######
## Deploy your pod
$ kubectl create -f pod/pod.yaml
## Get Pods
$ kubectl get pods
## Exec into your pod
$ kubectl exec -it pod bash
## Delete your pod
$ kubectl delete pod pod
## Deploy your replica set
$ kubectl create -f replicaset/replicaset.yml
## Get Pods
$ kubectl get pods
## Delete your pod
$ k delete pod replica-set-l3zbz
pod "replica-set-l3zbz" deleted
## Edit your replica set and change 'Image: nginx:1.12' to 'Image: nginx:1.13'
$ kubectl edit replicaset replica-set
## Create your persistent disk
$ kubectl create -f persistent-disk.yml
## Get your persistent volume claim
$ kubectl get pvc
## Create your secret
$ kubectl create secret generic mysql-pass --from-file=password.txt
## Deploy MySQL
$ kubectl create -f mysql-deployment.yaml
## Check pod is running
$ kubectl get pods
## Deploy Wordpress
$ kubectl create -f wordpress-deployment.yaml
## Get pods
$ kubectl get pods
## Check logs
$ kubectl logs wordpress-1595585052-9m5vm
## Get service
$ kubectl get svc wordpress
## Expose via ELB (change type: ClusterIP to type: LoadBalancer)
$ kubectl edit svc wordpress
## Get ELB
$ kubectl get svc wordpress -o wide
## Edit our deployment (change tag from wordpress-4.7.3-apache to wordpress-4.8.0-apache
$ kubectl edit deployment wordpress
## Check our pods are upgrading
$ kubectl get pods
## Deploy StatefulSet
$ kubectl create -f statefulsets/
## Watch pods come up
$ kubectl get pods -w
## Start a CockroachDB client pod
$ kubectl run -it --rm cockroach-client --image=cockroachdb/cockroach --restart=Never --command -- ./cockroach sql --host cockroachdb-public --insecure
## Show databases
SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| crdb_internal |
| information_schema |
| pg_catalog |
| system |
+--------------------+
(4 rows)
## Create a Database
root@cockroachdb-public:26257/> CREATE DATABASE IF NOT EXISTS dodams;
## Create a table
root@cockroachdb-public:26257/> CREATE TABLE IF NOT EXISTS dodams.demo (k STRING PRIMARY KEY, v STRING);
## Insert values
root@cockroachdb-public:26257/> UPSERT INTO dodams.demo VALUES('We', 'Love'), ('Devops', 'Days');
## Select results
root@cockroachdb-public:26257/> SELECT * FROM dodams.demo;
## In another tab, kill a pod
$ kubectl delete pod cockroachdb-2
## Test our cluster survives on the first tab
root@cockroachdb-public:26257/> SELECT * FROM dodams.demo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment