Skip to content

Instantly share code, notes, and snippets.

View dleske's full-sized avatar

Drew Leske dleske

  • Victoria, Canada
View GitHub Profile
@dleske
dleske / k8s-unable-to-communicate.log
Created February 21, 2018 15:40
k8s unable to communicate log
E0220 06:48:00.109771 1 event.go:209] Unable to write event: 'Post https://localhost:6443/api/v1/namespaces/default/events: dial tcp 127.0.0.1:6443: getsockopt: connection refused' (may retry after sleeping)
E0220 06:48:00.109837 1 reflector.go:205] k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion/factory.go:85: Failed to list *core.Service: Get https://localhost:6443/api/v1/services?limit=500&resourceVersion=0: dial tcp 127.0.0.1:6443: getsockopt: connection refused
E0220 06:48:00.109978 1 reflector.go:205] k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion/factory.go:85: Failed to list *core.Endpoints: Get https://localhost:6443/api/v1/endpoints?limit=500&resourceVersion=0: dial tcp 127.0.0.1:6443: getsockopt: connection refused
E0220 06:48:01.110568 1 reflector.go:205] k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion/factory.go:85: Failed to list *core.Service: Get https://localhost:6443/api/v1/services?lim
@dleske
dleske / k8s-cheat-sheet.md
Created February 22, 2018 19:06
Kubernetes Cheat Sheet

Kubernetes Cheat Sheet

kubectl

get OS information about all nodes

Or use as a pattern for other queries. Replace the OS image JSON path with whatever you want.

$ kubectl get nodes -o custom-columns='NAME:.metadata.name,OS:.status.nodeInfo.osImage'
@dleske
dleske / k8s-cl-update-breaks-flannel.md
Last active February 23, 2018 05:35
k8s: Container Linux breaks Flannel after update/reboot

Original message in kubernetes-novice Slack:

I am using Container Linux with Kubespray and I have found that after a short while new deployments all fail due to pod errors with: Pod sandbox changed, it will be killed and re-created. and subsequently, Failed create pod sandbox. This happens repeatedly. It appears that the issue is due to Container Linux automatically updating itself and rebooting the node. In the end, deployments only work on the masters, which have a No reboots update strategy, but in my understanding this only means the masters will not reboot automatically--the update is still downloaded and if/when the masters are rebooted, they will also be in the same state. I have compared a node that hasn’t yet updated to an updated node and can’t find any differences. Has anybody else seen this?

Took it to #kubespray on advice of a friendly user. Others have seen it but were messing about with routing and such. Furth

@dleske
dleske / dirtydict.py
Created February 12, 2020 17:39
Dirty Dict for Python
class DirtyDict(dict):
"""
DirtyDict behaves (hopefully) like a regular dict but overrides mutator
methods to mark the dictionary dirty. In this way changes to the data are
tracked in order to, for example, keep related database objects in sync.
"""
def __init__(self, *args, **kwargs):
self._dirty = False
self._created = []
@dleske
dleske / update-on-upstream.sh
Last active September 15, 2020 18:04
Trigger Docker image rebuild on upstream update
#!/bin/sh
#
# Checks if upstream image has been updated, and if so, triggers automatic build
# on Dockerhub. Use this for official images, which are no longer directly supported
# by Dockerhub's automatic builds.
#
# Assumes presence of "notify" script which takes a title, message, and optional
# reference URL.
#
# Create a build trigger in your Docker Hub repository via
@dleske
dleske / Makefile
Last active February 16, 2022 19:11
pdoc/mako template for generating simple Markdown documentation from Python docstring
docs/%.md: myapp/%.py misc/pdoc-templates/text.mako
@pdoc3 --template-dir=misc/pdoc-templates myapp.$* > $@
docs: docs/mymodule.md docs/othermodule.md
@dleske
dleske / grokcerts.py
Created October 23, 2022 21:10
Python script to parse certificate data from Terraform output
#!/usr/bin/env python3
#
# Reads certificate information from Terraform output and creates certificate
# files ready for use.
#
# If Terraform variable for certificates is defined like:
#
# variable certificates {
# type = map(string)
# default = {}
@dleske
dleske / harbor-2.8.2-install-support-systemd.patch
Created July 27, 2023 00:05
Patch for Harbor 2.8.2's install script to support systemd
diff -uNr harbor.orig/install.sh harbor/install.sh
--- harbor.orig/install.sh 2023-06-02 11:46:12.000000000 +0000
+++ harbor/install.sh 2023-07-26 18:04:48.666624099 +0000
@@ -19,6 +19,8 @@
with_clair=$false
# trivy is not enabled by default
with_trivy=$false
+# assume no systemd for now
+have_systemd=$false
@dleske
dleske / k8s-update-secret.md
Last active January 29, 2024 17:12
k8s: Updating a Secret

Hopefully helped another k8s newbie with the following. The question was, how do you update a single key in a secret in k8s? I don't know anything about secrets but I will probably want to know this in the future, so here we go.

First, to create a dummy secret:

apiVersion: v1
kind: Secret
metadata:
  name: test-secret
data: