Random TILs

Misc notes about K8s

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