peopledata-cli v1.2.44
peopledata-cli
A collection of utilities that help us do development, CI and CD. Specifically on GCP/GKE and Kubernetes.
Getting started
Do a global install... npm install -g peopledata-cli
Kubernetes
A bunch of common kubernetes commands are wrapped, however we do output the underlying kubernetes command that is being executed - just so that people know what is going on.
Applications
We use the term 'app', but app is synologous with 'pod' for the purposes of this documentation.
Listing Apps
$ pdata app list
-> kubectl get pods --output=json
┌───────────────────────────────┬──────────┬──────────────────┐
│ Pod Name │ Status │ Labels │
├───────────────────────────────┼──────────┼──────────────────┤
│ gocd-agent-2493599176-bycc5 │ Running │ app=gocd-agent │
│ gocd-agent-2493599176-scvc7 │ Running │ app=gocd-agent │
│ gocd-master-1388090259-9tkmm │ Running │ app=gocd-master │
│ gocd-nginx-2641456012-3ts30 │ Running │ app=gocd-nginx │
└───────────────────────────────┴──────────┴──────────────────┘
Deploying Apps
We use GKE Registry and have images for each build of our docker image, and they're tagged with the build number. For example eu.gcr.io/yourteam/yourapp:buildnumber
. As a result, we wanted to be able to template the kubernetes .yml files with environment variables, so we can CI/CD everything. You do this by using {{ENV.THING}} in your file, for example:
containers:
- name: master
image: eu.gcr.io/yourteam/yourapp:{{ENV.GO_PIPELINE_COUNTER}}
You can deploy a single .yml
file with pdata app deploy yourfile.yml
, or you can deploy all .yml
files in the current directory with pdata app deploy --all
.
Other flags you might be interested in are:
--brutal
, this will delete and recreate resources, rather than doing an apply.--secrets
, this is quite team specific, but will deploy any secrets found in$pwd/secrets/$APP_ENV
. I'm still not totally happy with secret management from a CI CD perspective.--wait-for-deployment
, this will wait for a Kubernetes deployment to complete and all pods to be up before passing the build.
Destroying an App
The general idea here is that an app is composed of numerous kubernetes components, be it pods
, persistent volumes
, services
etc. By convention, if you tag them all with app=
you can bulk destroy them too with pdata app destroy label
.
Entering an app
Entering pods with kubernetes pre 1.3.0 is kind of annoying, as the terminal is set at a fixed size of 80x24. This script will detect your current terminal window and pass those sizes through.
You can also enter a pod with a partial pod name, rather than needing the whole lengthy thing:
$ pdata pods enter nginx
-> kubectl get pods --output=json
-> kubectl exec -it gocd-nginx-2641456012-3ts30 env COLUMNS=204 LINES=56 TERM=xterm bash
[root@gocd-nginx-2641456012-3ts30 storage]# exit
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago