Kubernetes Cheatsheet
The get parameter is a powerful way of discovering your kubenetes resources. You can use it to query:
- namespace
- pod
- node
- deployment
- service
- replicasets
$ kubectl get nodes$ kubectl get ns # ns is an abreviation for namespace$ kubectl get pods -n kube-system
The create command can do just that for:
- service
- cronjob
- deployment
- job
- namespace (or ns)
$ kubectl create ns hello-world$ kubectl create cronjob my-cronjob --image=alpine --schedule="*/15 * * * *" -- echo "hi there"
By Gregg
read moreExtract a Single File from a Tarball
Suppose I have a tarball (.tar.gz file) which is large and I only want to extract a specific file from it. If I know the name of the file all I have to do is pass the file’s relative path that it is stored under to the command line.
Here is an example of the error you will get if you pass the incorrect file specification:
$ tar zxvf dirtree-tarball.tar.gz file-7-30003.txt
tar: file-7-30003.txt: Not found in archive
Since I don’t have the full path, I can just search for it:
By Gregg
read moreUpdating My Home Lab using Ansible
I have a variety of Raspberry Pis that I use for various tasks like my Tiny-Tiny RSS server, Gitea server, and Calibre server among other things. In order to keep them updated I use Ansible.
My update script is fairly simple:
$ cat update-pis.sh
#!/bin/bash
ansible-playbook ./playbooks/apt.yml --user memyselfandi \
--ask-pass --ask-become-pass -i ./inventory/hosts $@
The YAML playbook is likewise very simple:
$ cat ./playbooks/apt.yml
- hosts: "*"
become: yes
tasks:
- name: Update System Package Cache (apt)
apt:
update_cache: yes
upgrade: 'yes'
- name: Upgrade System Packages (apt)
apt: upgrade=full
- name: Remove unused dependencies
apt: autoremove=true
- name: Check if reboot is required
shell: "[ -f /var/run/reboot-required ]"
failed_when: False
register: reboot_required
changed_when: reboot_required.rc == 0
notify: reboot
handlers:
- name: reboot
command: /sbin/reboot
Although I can run this in a cronjob, I tend to run it manually (for now). I’m thinking about doing some major revisions to my Pi configuration anyway. Stay tuned for more on that subject.
By Gregg
read more