- Namespaces
- List all namespaces:
kubectl get namespace
- Set a namespace:
kubens <namespace-name>
- See currently set namespace: kubens -c
- List all namespaces:
- Pods
- List all pods:
kubectl get pods
- List all pods in specific namespace:
kubectl get pods -n <namespace>
- Kill a pod:
kubectl delete pod <pod-name>
- Describe/get details of pod:
kubectl describe pods <pod-name>
- InitContainers
- Get logs: First describe the pod and look for the name of the init container. Then run
kubectl logs <pod-name> -c <init-container-name>
- Get logs: First describe the pod and look for the name of the init container. Then run
- List all pods:
- Deployments
- Get the manifest for a
Category: Computers
All things computing.
helm Cheat Sheet
Development Tips and Tricks
Test Template Rendering
Run the following. Instead of it installing the chart it will render the template and display the output
helm install --debug --dry-run <release-name> <path-to-chart-dir>
To test with an overriding value
helm install <release-name> <path-to-chart-dir> --dry-run --debug --set k=v
Deployments
- List releases:
helm list
- Get the manifest for a release:
helm get manifest <release-name[flags]
Implementing a Stack in Go
One of the key features in go is simplicity. As a result there are a number of utilities and data structures that are common in other high-level languages that do not come with the go stdlib.
One of them is a stack. Following is a very simple implementation of a stack that uses a slice to store the data.
The following is an implementation of a simple stack that takes any kind of pointer.
import "fmt"
type Stack[T any] struct
→ Continue reading “Implementing a Stack in Go” curl HTTPS Over an SSH Tunnel
If you want to execute curl commands on your local machine and connect to an HTTPS server that is only reachable from a bastion or other host through which you can only get to via SSH, the following is how you set up the SSH tunnel and execute the curl command.
The following will not work
# Create ssh tunnel
#
ssh -L localhost:8443:example.com:443 user@bastion.example.com
# Attempt to hit the endpoint otherwise accessible from bastion.example.com
# with curl -X GET
→ Continue reading “curl HTTPS Over an SSH Tunnel” Diffing the output of two commands
The GNU diff command on most Linux and UNIX systems will diff the contents of two files. With Bash, you can, using process substitution, take the output of any arbitrary command and process its input, or output, as a file descriptor. In this way, you can then use diff against the output of two commands as follows
diff <(cmd1) <(cmd2)
Both cmd1
and cmd2
will appear as a file name/file descriptor. The <
character indicates that the file descriptor should → Continue reading “Diffing the output of two commands”
Creating Custom Vagrant Boxes for Integration Testing
For some things, a docker container will not work. For example, I am working on a Python project to automate the deployment and configuration of VMs and bare-metal boxes. It involves installing packages and configuring the OS and to properly test it requires a full fledged VM and not just a container.
Use packer to define the box you want to build
Install packer. The description straight from apt show packer
is “HashiCorp Packer – A tool for creating identical → Continue reading “Creating Custom Vagrant Boxes for Integration Testing”
Using Environment Variables in a Vagrant File
An easy way to parameterize a Vagrant file is to use environment variables. You simply need to export a variable and then refer to it in the Vagrant file with the following syntax.
Export the variable:
export SSH_PORT=22222
Sample Vagrant file that reads the exported variable
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "debian/bullseye64"
config.vm.box_version = "11.20221219.1"
config.vm.network "forwarded_port", guest: 22, host: ENV['SSH_PORT']
end
→ Continue reading “Using Environment Variables in a Vagrant File” Declaring, Exporting, and Reading Dynamic Variables in Bash
If you want to dynamically define and export variable names in Bash here is the TLDR;
# Define the name of the variable
key="my-dynamic-var-name"
# Declare it and export it
declare -gx "$key"="some-value"
To then access that value via a dynamically generated variable name
# Create a variable that contains the variable name
var_to_access="my-dynamic-var-name"
# Read the value
my_var_value=${!var_to_access}
Read the man page for declare
for more details and read this article for a really good explanation and further examples.→ Continue reading “Declaring, Exporting, and Reading Dynamic Variables in Bash”
[SOLVED] ‘Virtualized Intel VT-x/EPT is not supported on this platform. Continue without virtualized Intel VT-x/EPT’ on Windows 11 host
I was trying to run a Debian, Linux, guest on a Windows 11 Enterprise host with virtualization enabled for the VMWare Linux guest so that I could install minikube. Minikube requires running a VM on the host on which minikube is running, so essentially, a VM within a VM.
After enabling the “Virtualize Intel VT-x/EPT or AMD-V/RVI” setting and attempting to boot the VM it indicated that this configuration was not supported on this platform.
After quite a bit of → Continue reading “[SOLVED] ‘Virtualized Intel VT-x/EPT is not supported on this platform. Continue without virtualized Intel VT-x/EPT’ on Windows 11 host”
How to check if a file is sourced in Bash
Sometimes you will want to ensure that a file is sourced instead of executed. This ensures, among other things, that any environment variables that the script defines remain in your current shell after the script completes.
To do so, use the following to check whether the file was sourced or run in a sub-shell
(return 0 2/dev/null) && sourced=1 || sourced=0
echo "sourced=$sourced"
Bash allows return statements only from functions and in a scripts top level scope IF it → Continue reading “How to check if a file is sourced in Bash”