➜ Create a HA production ready cluster with Kubespray
➜ Deploy the demo microservice
- Kubernetes/kubectl
- Python3
- pip3
- VirtualBox
- Gremlin account
Note: This repo uses kubespray and this demo microservice
-
clone the repo and cd into it
https://github.com/kubernetes-sigs/kubespray.git cd kubespray
-
Install dependencies
pip3 install -r requirements.txt
-
Bring up vagrant (this can take awhile)
vagrant up
-
Setup access to the cluster globally
#modify: group_vars/k8s-cluster/k8s-cluster.yml to kubeconfig_localhost: true #navigate to artifacts directory #/inventory/sample/artifacts cp admin.conf ~/.kube/config
-
Check nodes are up
kubectl get nodes kubectl get pods --all-namespaces
-
Navigate to the base directory
/gremlin
-
Create a namespace for the microservice
kubectl create namespace sock-shop
-
Deploy it
kubectl apply -f sock-shop.yaml
-
Check pods are running
kubectl get pods --namespace sock-shop #or kubectl get pods --namespace sock-shop --watch
-
Get front-end deployment port info
kubectl get deploy front-end -n sock-shop -o jsonpath='{.spec.template.spec.containers[?(@.name == "front-end")].ports[0].containerPort}' kubectl port-forward deploy/front-end -n sock-shop 3000:8079
-
Once logged in get the team id and secret key from the Teams page and download
-
Install the Gremlin client with helm
#NOTE:first change the env variables to match your team credentials helm repo add gremlin https://helm.gremlin.com
-
Create a namespace for the client
kubectl create namespace gremlin
-
Run to install (replace credentials)
export GREMLIN_TEAM_ID=<team-id> export GREMLIN_CLUSTER_ID=<cluster-di> #can be anything export GREMLIN_TEAM_SECRET=<team-scale> helm install gremlin gremlin/gremlin \ --namespace gremlin \ --set gremlin.secret.managed=true \ --set gremlin.secret.type=secret \ --set gremlin.secret.teamID=$GREMLIN_TEAM_ID \ --set gremlin.secret.clusterID=$GREMLIN_CLUSTER_ID \ --set gremlin.secret.teamSecret=$GREMLIN_TEAM_SECRET
-
In gremlin you can check and run attacks from the intuitive dashboard
https://app.gremlin.com/clients/hosts
or use the API
-
Clean up
helm uninstall -n gremlin gremlin vagrant halt vagrant destroy -f kubectl config use-context docker-desktop