Skip to content

Instantly share code, notes, and snippets.

@efossas
efossas / .gitlab-reference.yml
Created June 30, 2022 07:20
Gitlab Reference Tag (Yaml Anchor)
# define this in one file
.anchors:
install_vault:
- |
wget -q https://releases.hashicorp.com/vault/1.11.0/vault_1.11.0_linux_amd64.zip \
&& unzip -q vault_1.11.0_linux_amd64.zip \
&& mv -f vault /bin/vault \
&& rm -f vault_1.11.0_linux_amd64.zip;
# now use the reference anchor in separate file
@efossas
efossas / .gitlab-ci.yml
Created June 30, 2022 07:11
Gitlab Include
include:
- remote: 'http://cicd.example.com/1.x/stages.yml'
- remote: 'http://cicd.example.com/1.x/build.yml'
- remote: 'http://cicd.example.com/1.x/deploy.yml'
@efossas
efossas / clog.sh
Created June 30, 2022 07:08
Colorful Log
# clog 'this is a colorful log';
clog () { echo -e "\033[0;35m PIPELOG ${1} \033[0m"; };
@efossas
efossas / purge.sh
Created June 26, 2022 21:05
Kubectl Force Delete Pods Matching A Prefix And Age
# purge NAMESPACE PREFIX SECONDS
purge () {
kubectl get pod -o json -n $1 | jq -r --arg prefix "$2" --argjson timestamp $3 '.items[] | select(.metadata.name | startswith($prefix)) | select (.metadata.creationTimestamp | sub("\\..*";"Z") | sub("\\s";"T") | fromdate < now - $timestamp).metadata.name' | xargs -r -L1 kubectl delete pod -n $1 --grace-period=0 --force ;
}
@efossas
efossas / cycle.sh
Created June 16, 2022 23:44
Kubectl Cycle All Deployments
# cycle NAMESPACE
cycle () {
kubectl get deploy -n "$1" | cut -d' ' -f1 | tail +2 | while read line; do kubectl rollout restart deploy $line -n "$1"; done;
}
@efossas
efossas / k8gb-values.yml
Created April 23, 2022 01:37
K8gb Helm Values
k8gb:
dnsZone: "staging.example.com"
edgeDNSZone: "example.com"
edgeDNSServers: ["169.254.169.253"]
# the following two fields change based on which cluster you are installing on
clusterGeoTag: "cluster-1"
extGslbClustersGeoTags: "cluster-2,cluster-3"
route53:
@efossas
efossas / k8gb.sh
Created April 21, 2022 14:35
K8gb Install
helm upgrade k8gb k8gb \
--version 0.9.0 \
--repo https://www.k8gb.io \
--install --namespace gslb \
--values ./values.yml
@efossas
efossas / dnsendpoint.yaml
Created April 21, 2022 14:35
K8gb DNSEndpoint
apiVersion: externaldns.k8s.io/v1alpha1
kind: DNSEndpoint
metadata:
name: test
namespace: default
labels:
k8gb.absa.oss/dnstype: local
spec:
endpoints:
- dnsName: test.staging.example.com
@efossas
efossas / helm_rabbitmq.sh
Created February 17, 2022 22:49
RabbitMQ Operator Helm
helm repo add bitnami https://charts.bitnami.com/bitnami
helm upgrade pivotal bitnami/rabbitmq-cluster-operator \
--install --set useCertManager=true
@efossas
efossas / rabbitmqcluster.yaml
Last active March 11, 2022 15:12
RabbitmqCluster CRD
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: rabbit-cert
spec:
dnsNames:
- 'rabbit.default.svc.cluster.local'
- '*.rabbit-nodes.default.svc.cluster.local'
issuerRef:
kind: ClusterIssuer