Skip to content

Instantly share code, notes, and snippets.

mowings

Block or report user

Report or block mowings

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mowings
mowings / readme.md
Last active Aug 30, 2019
kubernetes. kubectl top pod -- cannot find pod
View readme.md

The deployjent yaml typically does not work out of the box. Fix deploy/1.8+/metrics-server-deployment.yaml as follows:

containers:
      - name: metrics-server
        image: k8s.gcr.io/metrics-server-amd64:v0.3.3
        imagePullPolicy: Always
        volumeMounts:
        - name: tmp-dir
          mountPath: /tmp
@mowings
mowings / kube-inst.sh
Created Aug 15, 2019
Kubernetes install on ubuntu. Assumes docker is already installed
View kube-inst.sh
#!/bin/sh
apt-get update && apt-get install -y apt-transport-https \
&& curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list
apt-get update \
&& apt-get install -y kubelet kubeadm kubernetes-cni
View websocket.go
package main
import (
"fmt"
"github.com/julienschmidt/httprouter"
"golang.org/x/net/websocket"
"net/http"
"log"
)
@mowings
mowings / kubernetes links.md
Last active Jun 30, 2019
kubernetes links
View kubernetes links.md
@mowings
mowings / cron_docker.md
Last active Jun 28, 2019
Run cron on docker with job output directed to stdout
View cron_docker.md

You'd like a docker container that runs cron jobs, with the output of those cron jobs going to stdout so they are accessible as docker logs. How do you do that?

Install cron, and set it up to run in the foreground

In your Dockerfile, apt-get -y install cron Use apk or whatever if you are running on alpine or another distribution Set the command or entrypoint in your Dockerfile to run cron 9n the foreground

ENTRYPOINT ["/usr/sbin/cron", "-f"]
@mowings
mowings / loop.sh
Last active Jun 30, 2019
Bash -- sleep until a specific time, like tomorrow midnight
View loop.sh
#!/bin/bash
# Sometimes you want to sleep until a specific time in a bash script. This is useful, for instance
# in a docker container that does a single thing at a specific time on a regular interval, but does not want to be bothered
# with cron or at. The -d option to date is VERY flexible for relative times.
# See
# https://www.gnu.org/software/coreutils/manual/html_node/Relative-items-in-date-strings.html#Relative-items-in-date-strings
# For details
# ALPINE USERS: You will need to install coreutils, as the built-in busybox date does not handle -d correctly.
@mowings
mowings / kubernetes node.md
Last active Jun 26, 2019
Add a new kubernetes node to existing cluster
View kubernetes node.md

Install the node software:

apt update && apt upgrade -y
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

cat <<EOF > /etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF

apt-get update
@mowings
mowings / ncq.md
Created Jun 24, 2019
Disable NCQ (disk command queuing in linux)
View ncq.md

There is a kernel option to do this, if it cauxes boot issues, but otherwise in /etc/rc.local you can just add

echo 1 > /sys/block/sdb/device/queue_depth

Normally the kernel disables it after too many errors automatically, but it can cause disk timeouts until that happens. Does not have much of a performance impact on ssds.

@mowings
mowings / kernel_cleanup.md
Last active Jun 20, 2019
Enable autoremove of old kernels from ubuntu /boot directory
View kernel_cleanup.md

edit /etc/apt/apt.conf.d/50unattended-upgrades

Uncomment line:

Unattended-Upgrade::Remove-Unused-Dependencies “false”;

and change to true

This all assumes unattended-upgrades is enabled (it usually is by default)

@mowings
mowings / k8.md
Last active May 14, 2019
Install Kubernetes at Digital Ocean using private networking
View k8.md

Install the software

Instructions mostly at https://vitux.com/install-and-deploy-kubernetes-on-ubuntu/ but be sure to read the notes below before starting.

additional setup

This document assumes all hosts are on the private network, and the hosts are configured to pass/allow all traffic on that network. You could tighten this up if you want, but k8 requires quite a range of ports be open.

Be sure the --apiserver-advertise-address=<private ip> parameter is passed to kubeadm init on any master host. By default, the api-server will attempt to advertise on the public interface.

You can’t perform that action at this time.