Skip to content

Instantly share code, notes, and snippets.

View cxhercules's full-sized avatar
🏠
Working from home

Christian Hercules cxhercules

🏠
Working from home
  • cxh
  • CA
View GitHub Profile
@cxhercules
cxhercules / helm-value-trick.md
Last active June 18, 2019 17:17
Processing helm variables in values file

You need to use a tpl trick to interpolate the value, since helm variable in values are not processed, you have to update your deployment, for example:

In your values.yaml:

  tag: "{{ .Chart.AppVersion }}"

In your deployment:

 image: "{{ .Values.api.image.repository }}:{{ tpl .Values.api.image.tag . }}"
@cxhercules
cxhercules / awk-system.sh
Created February 12, 2019 22:50
awk run system command against field
#!/bin/bash
cat secrets-alone.yml |awk -F: '{ printf "export %s=",$1; system ("echo "$2"|base64 -d "); system("echo")}'
# Drain and delete the nodes (for each node you have)
kubectl drain kubenode1 --delete-local-data --force --ignore-daemonsets
kubectl delete node kubenode1
# Reset the deployment
sudo kubeadm reset
# On each node
## Reset the nodes and weave
openssl x509 -in /etc/kubernetes/pki/ca.crt -noout -pubkey | openssl rsa -pubin -outform DER 2>/dev/null | sha256sum | cut -d' ' -f1
Reference:
https://github.com/kubernetes/kubeadm/issues/659#issuecomment-392822587
@cxhercules
cxhercules / k8s-user-data.sh
Created December 27, 2018 06:04 — forked from MeenachiSundaram/k8s-user-data.sh
kubernetes user data script
#!/bin/bash
apt-get update
apt-get install -y git wget
# Install Docker
apt-get install \
apt-transport-https \
ca-certificates \
curl \

Read from vault without saving secret value

vault read -field=value "secret/gcp-creds/${SERVICE_ACCOUNT_PROJECT_ID}/${SERVICE_ACCOUNT_NAME}.json" \
  | gcloud auth activate-service-account "${SERVICE_ACCOUNT_EMAIL}" --key-file -
VBoxManage controlvm minikube natpf1 k8s-apiserver,tcp,127.0.0.1,8443,,8443
kubectl config set-cluster minikube-vpn --server=https://127.0.0.1:8443 --insecure-skip-tls-verify
kubectl config set-context minikube-vpn --cluster=minikube-vpn --user=minikube
kubectl config use-context minikube-vpn
VBoxManage controlvm minikube natpf1 k8s-dashboard,tcp,127.0.0.1,30000,,30000
VBoxManage controlvm minikube natpf1 docker,tcp,127.0.0.1,2376,,2376
minikube docker-env|sed 's/192.168.99.101/127.0.0.1/'
@cxhercules
cxhercules / pem-split
Created August 23, 2018 15:34 — forked from jinnko/pem-split
Take a PEM format file as input and split out certs and keys into separate files.
#!/usr/bin/awk -f
#
# Take a PEM format file as input and split out certs and keys into separate files
#
BEGIN { n=0; cert=0; key=0; if ( ARGC < 2 ) { print "Usage: pem-split FILENAME"; exit 1 } }
/-----BEGIN PRIVATE KEY-----/ { key=1; cert=0 }
/-----BEGIN CERTIFICATE-----/ { cert=1; key=0 }
split_after == 1 { n++; split_after=0 }
/-----END CERTIFICATE-----/ { split_after=1 }
@cxhercules
cxhercules / helm-recover.md
Last active August 12, 2018 16:58
Recover item you have deleted from helm deployment

I looked around and did not find an answer to this so just sharing.

I deployed a jenkins chart using below command:

helm install -n cd stable/jenkins -f jenkins/values.yaml --version 0.16.6 --wait

Then I wanted to remove external load balancer for a bit, just testing some things so removed it by:

@cxhercules
cxhercules / readme.md
Created August 12, 2018 16:51 — forked from benstr/readme.md
Gist Markdown Cheatsheet

#Heading 1 ##Heading 2 ###Heading 3 ####Heading 4 #####Heading 5 ######Heading 6


Paragraph