Skip to content

Instantly share code, notes, and snippets.

@phosae
Last active January 2, 2024 01:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phosae/05da38d8f621538f2003e98648cadab1 to your computer and use it in GitHub Desktop.
Save phosae/05da38d8f621538f2003e98648cadab1 to your computer and use it in GitHub Desktop.
How-To-Kubernetes

How-To-Kubernetes

Basics

Design Proposals

Network

Scheduler

extend-kubernetes

Rootless

alpha at Kubernetes v1.25

Kubernetes Official Docs Conditions:

  • at least Linux 6.3, as tmpfs started supporting idmap mounts in that version (the service account token that is mounted by default uses a tmpfs, Secrets use a tmpfs, etc.)
  • CRI-O: version 1.25 (and later) supports user namespaces for containers
  • containerd v1.7+

Limitations, if you set hostUsers: false then you are not allowed to set any of:

  • hostNetwork: true
  • hostIPC: true
  • hostPID: true

The pod is allowed to use no volumes at all or, if using volumes, only these volume types are allowed:

  • configmap
  • secret
  • projected
  • downwardAPI
  • emptyDir

K8s Proposals

Runtime Status

RootlessKit

Others

Container is not for multi-tenant

Kata

kubectl cheat sheet

raw api output JSON

kubectl get --raw /api/v1/pods

{
  "kind": "PodList",
  "apiVersion": "v1",
  "metadata": {
    "resourceVersion": "6196466"
  },
  "items": []
}

list Pods that refer to the ConfigMap name

kubectl get po -n dora3-env-dev -o json | jq -r '.items | map(select(.spec.volumes[]?.configMap.name == "boots-proxy-service-config" ) | .metadata.name) | .[]' | uniq

Kubermark Dockerfile

FROM golang:1.20.3-bullseye as builder

RUN apt update && apt install -y rsync
RUN mkdir -p /go/src/k8s.io
RUN mkdir -p ./src/k8s.io
RUN cd src/k8s.io && git clone https://github.com/kubernetes/kubernetes.git && cd kubernetes && make all WHAT=cmd/kubemark GOFLAGS=-v

FROM registry.k8s.io/build-image:v2.3.1-go1.20.3-bullseye.0

COPY --from=builder /go/src/k8s.io/kubernetes/_output/bin/kubemark /kubemark

How Pause Works

sig controller

index objects and get objects by index

func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
	// index pods by nodeName
  mgr.GetFieldIndexer().IndexField(context.Background(), &corev1.Pod{}, "spec.nodeName", func(rawObj client.Object) []string {
		pod := rawObj.(*corev1.Pod)
		return []string{pod.Spec.NodeName}
	});
}

// get pods by nodeName
var pdList corev1.PodList
err := r.List(ctx, &pdList, &client.MatchingFields{"spec.nodeName": node})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment