Sunday, 18 June 2017

Sportsworkout.com/chart.htm


I was reading 'The Ultimate Guide to Weight Training for Gymnastics', and went to download the training cards from sportsworkout.com/chart.htm but the site has gone and I couldn't find the training cards anywhere!

I created a set of training cards and I'm sharing it here to save others the hassle! I'll upload a PDF version of this file if anyone asks for it (I couldn't upload it here unfortunately, so it would be hosted somewhere else), but a JPEG version is below.


Note that Blogger reduces the size/quality of the JPEG so if anyone wants the originals just say 'post the originals' in the comments and I'll upload them to GitHub.

Enjoy!

Friday, 16 June 2017

How to include a subdirectory of an excluded directory

This post is for the Obdi Rsync Backup plugin.


So you have a backup configuration for a server with a bunch of excludes and now you need to explicitly include just one directory, but a parent of that directory is explicitly excluded. What do you do?

Add a new Host entry.

The graphic at the top of this post shows how. In that graphic the top line has '/opt/work/**' excluded. The next line has a new host (which is actually the same host) but with the full path, 'backup/opt/work/perfci_result_trends', shown for the Include.

That's all :)

Wednesday, 7 June 2017

JSONPath Cheat Sheet

I'll keep adding to this post. JSONPath.sh is required.

  1. List all containers in a Kubernetes system Pod
  2. Get the Internal IP Address of all Kubernetes Nodes
  3. Show all the Volume Mounts for a Pod
  4. Modify the Number of Replicas in a Kubernetes Deployment

List all containers in a Kubernetes system Pod

Get the list of System Pods

$ kubectl get -n kube-system pods
NAME                                    READY     STATUS    RESTARTS   AGE
etcd-k8s1                               1/1       Running   0          26d
kube-apiserver-k8s1                     1/1       Running   1          26d
kube-controller-manager-k8s1            1/1       Running   0          26d
kube-dns-3913472980-mbxbg               3/3       Running   0          26d
kube-proxy-7r5p1                        1/1       Running   0          26d
kube-proxy-l6dq4                        1/1       Running   0          26d
kube-proxy-rsdbd                        1/1       Running   0          26d
kube-scheduler-k8s1                     1/1       Running   0          26d
kubernetes-dashboard-2039414953-bb1jx   1/1       Running   0          13d
weave-net-pfv92                         2/2       Running   0          22d
weave-net-tnwjt                         2/2       Running   35         22d
weave-net-xnfk9                         2/2       Running   34         22d


Find the names of all the containers in the weave-net-pfv92 Pod

$ kubectl get -n kube-system pods weave-net-pfv92 -o json \
    | JSONPath.sh '..containers[*].name' -b

weave
weave-npc

Get the Internal IP Address of all Kubernetes Nodes

 $ kubectl get nodes -o json | JSONPath.sh -b \
    '..addresses[?(@.type=="InternalIP")].address'
172.42.42.1
172.42.42.2
172.42.42.3

Show all the Volume Mounts for a Pod

$ kubectl get -n kube-system pods etcd-k8s1 -o json \
    | JSONPath.sh -j '..[volumeMounts,volumes]'

{
    "spec":
    {
        "containers":
        [
            {
                "volumeMounts":
                [
                    {
                        "mountPath":"/etc/ssl/certs",
                        "name":"certs"
                    },
                    {
                        "mountPath":"/var/lib/etcd",
                        "name":"etcd"
                    },
                    {
                        "mountPath":"/etc/kubernetes/",
                        "name":"k8s",
                        "readOnly":true
                    }
                ]
            }
        ],
        "volumes":
        [
            {
                "hostPath":
                {
                    "path":"/etc/ssl/certs"
                },
                "name":"certs"
            },
            {
                "hostPath":
                {
                    "path":"/var/lib/etcd"
                },
                "name":"etcd"
            },
            {
                "hostPath":
                {
                    "path":"/etc/kubernetes"
                },
                "name":"k8s"
            }
        ]
    }
}

Modify the Number of Replicas in a Kubernetes Deployment


The following "one-liner" will change 'spec.replicas' to 2 for hello-deployment:
$ kubectl get deployment hello-deployment -o json | \
    JSONPath.sh | \
    sed 's/\["spec","replicas"\].*/["spec","replicas"]\t2/' | \
    JSONPath.sh -p | \
    kubectl replace deployment hello-deployment -f -

deployment "hello-deployment" replaced
Or you could use a bash function and reuse at will.
Set the bash function:
$ change_replicas() { kubectl get deployment $1 -o json | \
JSONPath.sh | \
sed 's/\["spec","replicas"\].*/["spec","replicas"]\t'"$2"'/' | \
JSONPath.sh -p | \
kubectl replace deployment $2 -f - ;}
Then use it:
$ change_replicas hello-deployment 4
deployment "hello-deployment" replaced
$ change_replicas hello-deployment 1
deployment "hello-deployment" replaced