Random TILs
Misc notes about K8s
--show labels
will show you all the labels!- A podsec can be configured to connect to the Kubernetes API server its running on (so for example, you can use Kubectl commands). I didn’t try to do this yet.
Abbreviations
You can get a list of the short abbrevations for resources like this:
$ kl api-resources --sort-by name
NAME SHORTNAMES APIVERSION NAMESPACED KIND
apiservices apiregistration.k8s.io/v1 false APIService
bindings v1 true Binding
certificatesigningrequests csr certificates.k8s.io/v1 false CertificateSigningRequest
clusterrolebindings rbac.authorization.k8s.io/v1 false ClusterRoleBinding
clusterroles rbac.authorization.k8s.io/v1 false ClusterRole
componentstatuses cs v1 false ComponentStatus
configmaps cm v1 true ConfigMap
controllerrevisions apps/v1 true ControllerRevision
cronjobs cj batch/v1 true CronJob
csidrivers storage.k8s.io/v1 false CSIDriver
csinodes storage.k8s.io/v1 false CSINode
csistoragecapacities storage.k8s.io/v1 true CSIStorageCapacity
customresourcedefinitions crd,crds apiextensions.k8s.io/v1 false CustomResourceDefinition
daemonsets ds apps/v1 true DaemonSet
deployments deploy apps/v1 true Deployment
endpoints ep v1 true Endpoints
endpointslices discovery.k8s.io/v1 true EndpointSlice
events ev v1 true Event
events ev events.k8s.io/v1 true Event
flowschemas flowcontrol.apiserver.k8s.io/v1beta2 false FlowSchema
horizontalpodautoscalers hpa autoscaling/v2 true HorizontalPodAutoscaler
ingressclasses networking.k8s.io/v1 false IngressClass
ingresses ing networking.k8s.io/v1 true Ingress
jobs batch/v1 true Job
leases coordination.k8s.io/v1 true Lease
limitranges limits v1 true LimitRange
localsubjectaccessreviews authorization.k8s.io/v1 true LocalSubjectAccessReview
mutatingwebhookconfigurations admissionregistration.k8s.io/v1 false MutatingWebhookConfiguration
namespaces ns v1 false Namespace
networkpolicies netpol networking.k8s.io/v1 true NetworkPolicy
nodes no v1 false Node
persistentvolumeclaims pvc v1 true PersistentVolumeClaim
persistentvolumes pv v1 false PersistentVolume
poddisruptionbudgets pdb policy/v1 true PodDisruptionBudget
pods po v1 true Pod
podtemplates v1 true PodTemplate
priorityclasses pc scheduling.k8s.io/v1 false PriorityClass
prioritylevelconfigurations flowcontrol.apiserver.k8s.io/v1beta2 false PriorityLevelConfiguration
replicasets rs apps/v1 true ReplicaSet
replicationcontrollers rc v1 true ReplicationController
resourcequotas quota v1 true ResourceQuota
rolebindings rbac.authorization.k8s.io/v1 true RoleBinding
roles rbac.authorization.k8s.io/v1 true Role
runtimeclasses node.k8s.io/v1 false RuntimeClass
secrets v1 true Secret
selfsubjectaccessreviews authorization.k8s.io/v1 false SelfSubjectAccessReview
selfsubjectrulesreviews authorization.k8s.io/v1 false SelfSubjectRulesReview
serviceaccounts sa v1 true ServiceAccount
services svc v1 true Service
statefulsets sts apps/v1 true StatefulSet
storageclasses sc storage.k8s.io/v1 false StorageClass
subjectaccessreviews authorization.k8s.io/v1 false SubjectAccessReview
tokenreviews authentication.k8s.io/v1 false TokenReview
validatingwebhookconfigurations admissionregistration.k8s.io/v1 false ValidatingWebhookConfiguration
volumeattachments storage.k8s.io/v1 false VolumeAttachment
DBs on K8s
Don’t do it. Use a managed DB from your cloud provider instead.
Further Reading
Jeremy Lewi recommends KubeBuilder. I used it to understand Kinds, Resources, Groups and Versions.
Creating A custom controller with python
- Example of writing your own operator/controller with python using
kopf
: repo - The official python client for K8s: repo
- A K8s slackbot written in python.
- Implementing a custom controller in python