Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View zedtux's full-sized avatar

Guillaume Hain zedtux

View GitHub Profile
@zedtux
zedtux / mysql-debug-pod.yaml
Created November 21, 2019 16:02
Kubernetes Debug pod to access PV from PVC name
apiVersion: v1
kind: Pod
metadata:
name: mysql-debug
spec:
containers:
- name: mysql-debug
image: mysql:5.7
command:
- sleep
@zedtux
zedtux / master.rb
Created July 29, 2019 13:23
An extracted part of a Chef recipe to deploy Kubernetes with Kubeadm logging in real-time the command output
require 'pty'
# Initialize master
ruby_block 'kubeadm init' do
block do
command = <<-CMD
kubeadm init \
--token=#{node['kubeadm']['token']} \
--pod-network-cidr=#{node['kubeadm']['pod_cidr']} \
--service-cidr=#{node['kubeadm']['service_cidr']} \
@zedtux
zedtux / master.rb
Last active July 29, 2019 13:23
An extracted part of a Chef recipe to deploy Kubernetes with Kubeadm
execute 'kubeadm init' do
command = <<-CMD
kubeadm init \
--token=#{node['kubeadm']['token']} \
--pod-network-cidr=#{node['kubeadm']['pod_cidr']} \
--service-cidr=#{node['kubeadm']['service_cidr']} \
--service-dns-domain=#{node['kubeadm']['dns_domain']} \
--apiserver-advertise-address=#{node['kubeadm']['api_ip_address']}
CMD
action :run
@zedtux
zedtux / sidekiq_override_delete_by_value.rb
Last active June 27, 2019 21:02
Overrides of the Sidekiq method to delete a job, transmit via ActionCable to the UI
require 'sidekiq/api'
module Sidekiq
class JobSet < SortedSet
alias :old_delete_by_value :delete_by_value
def delete_by_value(name, value)
parsed = JSON.parse(value)
CommisChannel::BackgroundTasks.broadcast_delete(parsed['jid'])
let ws = new WebSocket('wss://ws.domain.eu/cable/', ['actioncable-v1-json']);
ws.onopen = () => { console.log('WS Open') };
ws.onerror = (error) => { console.log('WS ERROR:', error) };
ws.onclose = () => { console.log('WS CLOSED') };
ws.onmessage = (message) => { console.log('WS message:', message) };
@zedtux
zedtux / do-volume.yaml
Created February 1, 2019 05:16
Kubernetes volume YAML file for DigitalOcean volumes
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: csi-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
@zedtux
zedtux / gitlab-ci-create_secret-function.sh
Last active January 25, 2019 11:54
Updated Gitlab CI create_secret function for Kubernetes solving the authentication issue to pull the images
#
# In order to get Kubernetes to be authorised to fetch the Docker images from
# the private gitlab registry, we are creating a docker-registry secret.
#
function create_gitlab_registry_secret() {
echo "Creating the gitlab-registry secret ..."
# Save the JSON to create the gitlab-registry docker-registry secret
GITLAB_REGISTRY_SECRET_JSON=$(
kubectl create secret --namespace=$KUBE_NAMESPACE \
docker-registry gitlab-registry \
@zedtux
zedtux / kubernetes-gitlab-deploy-updated-secret.sh
Last active January 25, 2019 11:39
Deploys the updated Kubernetes docker-registry secret
echo $FINAL_JSON | \
kubectl replace --namespace=$KUBERNETES_NAMESPACE \
--force \
-f -
@zedtux
zedtux / kubernetes-gitlab-update-secret-data.sh
Created January 25, 2019 11:38
Replaces the Kubernetes docker-registry secret data
# Updates the GITLAB_REGISTRY_SECRET_JSON with the removed auths key
# and replace the Kubernetes secret
FINAL_JSON=$(
echo $GITLAB_REGISTRY_SECRET_JSON | \
sed -e s"/\".dockerconfigjson\":\s\"\([a-zA-Z0-9=]\+\)\"/\".dockerconfigjson\":\"$AUTHS\"/"
)
@zedtux
zedtux / kubernetes-gitlab-extract-decode-update-encode-auths.sh
Created January 25, 2019 11:27
Extracts, decodes, updates and encodes the Kubernetes docker-registry secret in order to remove the auths root node
# Extracts the auths key from the decoded JSON
AUTHS=$(
echo $GITLAB_REGISTRY_SECRET_JSON | \
jq '.data[".dockerconfigjson"]' -r | \
base64 -d | \
jq '.auths' -c | \
base64 | \
tr -d '\n'
)