Created
May 14, 2017 20:20
-
-
Save thrawn01/d5f33030e4a2cf8f0d7d845865fcfa2f to your computer and use it in GitHub Desktop.
How we might make devgun more generic and useful for others.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: v1 | |
| downloads: | |
| - name: "helm" | |
| url: "https://storage.googleapis.com/kubernetes-helm/helm-v2.2.3-{{.Local.OS}}-amd64.tar.gz" | |
| cmds: | |
| - "tar zxpf {{.SrcFile}} -C {{.TempDir}}" | |
| - "cp -f {{.TempDir}}/{{.Local.OS}}-amd64/helm {{.BinDir}}" | |
| - name: "rocker" | |
| url: "https://github.com/grammarly/rocker/releases/download/%s/rocker_%s_amd64.tar.gz" | |
| cmds: | |
| - "tar zxpf {{.SrcFile}} -C {{.BinDir}}" | |
| - "chmod +x {{.BinDir}}/rocker" | |
| miniKube: | |
| memory: {{.Env.MINIKUBE_MEMORY || "6G"}} | |
| cpus: 2 | |
| disk-size: 25G | |
| kubernetes-version: v1.6.0 | |
| addons: | |
| - name: "heapster" | |
| - name: "ingress" | |
| # Before executing each command the 'waitFor' rules are executed, if all waitFor rules return | |
| # positive immediatly the 'run' command for each rule is skipped. | |
| rules: | |
| - name: "External DNS" | |
| run: "kubectl create -f kube-dns-expose-svc.yaml" | |
| # Wait for directive processes each type in order | |
| waitFor: | |
| # returns true when selector correctly matchs atleast 1 service | |
| - type: selector | |
| kind: service | |
| selector: "k8s-app=kube-dns-external" | |
| - name: "Weave Scope" | |
| run: "kubectl apply -f https://cloud.weave.works/launch/k8s/weavescope.yaml" | |
| waitFor: | |
| # returns true if matches a regex on the pod name | |
| - type: pod-exists | |
| regex: "weave-scope*" | |
| - name: "Init Helm" | |
| run: "helm init" | |
| waitFor: | |
| # returns true when the returns status matches | |
| - type: return-status | |
| equals: 0 | |
| cmd: "helm list" | |
| - name: "Etcd" | |
| run: "kubectl create -f etcd-service.yaml" | |
| waitFor: | |
| # returns true when selector correctly matchs atleast 1 pod | |
| - type: selector | |
| kind: pod | |
| selector: "app=etcd" | |
| - name: "Cassandra" | |
| run: | |
| - "kubectl create -f cassandra-service.yaml" | |
| - "kubectl create -f cassandra-statefuleset.yaml" | |
| waitFor: | |
| # Waits for 2 pods that match app=cassandra | |
| - type: selector | |
| kind: pod | |
| selector: "app=cassandra" | |
| count: 2 | |
| # Then waits for all pods that match this selector to report ready | |
| - type: pod-conditions | |
| selector: "app=cassandra" | |
| type: Ready | |
| value: True | |
| # Runs these subcommands after all services are succesfully up and running | |
| runSubComands: | |
| - reset-db # To initialize our cassandra tables | |
| - env # Inform users of useful aliases | |
| # These are additional commands for use on the command line by users | |
| subCommands: | |
| # This command will run a command on the casssandra instances to wipe all | |
| # the data and re-create all the tables | |
| - cmd: "reset-db" | |
| rules: | |
| # This rule has no `waitFor` so it will succeed imediatly after executing 'run' | |
| - name: "Reset cassandra database" | |
| run: "kubectl exec --tty -i cassandra-0 -- /usr/local/bin/reset-db.sh" | |
| # This command restarts cassandra completely by deleting all pods, services and pvc's | |
| - cmd: "restart cassandra" | |
| # Outputs this message and asks the user for Y/N answer before running the command | |
| message: "This command will delete all cassandra assets and data!" | |
| askToContinue: true | |
| rules: | |
| - name: "Delete Cassandra" | |
| run: "kubectl delete statefulsets -l app=cassandra" | |
| waitFor: | |
| - type: selector | |
| kind: statefuleset | |
| # inverse true, means this will return true only when the select | |
| # doesn't match a statefuleset | |
| inverse: true | |
| selector: "app=cassandra" | |
| - name: "Delete Pods" | |
| run: "kubectl delete pods -l app=cassandra" | |
| waitFor: | |
| - type: selector | |
| kind: pod | |
| inverse: true | |
| selector: "app=cassandra" | |
| - name: "Delete PVC" | |
| run: "kubectl delete pvc -l app=cassandra" | |
| waitFor: | |
| - type: selector | |
| kind: pvc | |
| inverse: true | |
| selector: "app=cassandra" | |
| - name: "Create Cassandra service" | |
| run: | |
| - "kubectl create -f cassandra-service.yaml" | |
| - "kubectl create -f cassandra-statefuleset.yaml" | |
| waitFor: | |
| - type: selector | |
| kind: pvc | |
| inverse: true | |
| selector: "app=cassandra" | |
| # devgun env | |
| - name: "env" | |
| # Perhaps commands can just have messages that are output to stdout when run? | |
| message: " | |
| # Useful aliases | |
| alias cqlsh='kubectl exec --tty -i cassandra-0 -- /usr/local/bin/cqlsh.sh' | |
| alias etcdctl='kubectl exec etcd-0 -- /etcdctl' | |
| # Run this command to configure your shell: | |
| # eval $(devgun minikube env) | |
| " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment