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 / lxc-2x-ubuntu.md
Last active Sep 29, 2019
Getting lxc 2.x running on ubuntu 18
View lxc-2x-ubuntu.md

I won't lie -- it's ugly

Go grab the latest 2x source release from github. Be sure you have automake and libcap-dev installed before starting. Be sure you fully delete and 3x stuff if you installed it. This includes shared libraries.

Follow the instructions for building and installing. The catch, here, is that everything is going to be installed and run under /usr/local. You may need to run ldconfig after installation to pick up the shared lib directorues, and many programs that automate lxc operations will not be expecting stuff to be installed under /usr/local.

In particular, what used to be /var/lib/lxc will now be under /usr/local/var/lib/lxc, so you may need a symlink. We

@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)

You can’t perform that action at this time.