Caleb Woodbine <calebwoodbine.public@gmail.com>
based in Wellington, New Zealand. Software and infrastructure engineer. Cloud & Open Source enthusiast.
into test writing with Kubernetes and Go.
...
- pkg/
- cmd/
- test/
- e2e/
- apps/
- scheduling/
...
- conformance/
- testdata/
- conformance.yaml
...
...
...
reading and building mental-models
pods, err := clientset.CoreV1().Pods("").List(context.TODO(), metav1.ListOptions{})
matches up with /api/v1/pods
deployments, err := clientset.AppsV1().Deployments("").List(context.TODO(), metav1.ListOptions{})
matches up with /apis/apps/v1/deployments
RESOURCE, err := clientset.APIGROUP().API("").ACTION(context.TODO(), ...)
matches up with /apis/APIGROUP/VERSION/API
kubectl
goodnesspowerful to explore when working inside a cluster
kubectl get --raw /
{
"paths": [
"/.well-known/openid-configuration",
"/api",
"/api/v1",
"/apis",
"/apis/",
"/apis/admissionregistration.k8s.io",
"/apis/admissionregistration.k8s.io/v1",
"/apis/apiextensions.k8s.io",
"/apis/apiextensions.k8s.io/v1",
"/apis/apiregistration.k8s.io",
"/apis/apiregistration.k8s.io/v1",
"/apis/apps",
"/apis/apps/v1",
"/apis/authentication.k8s.io",
"/apis/authentication.k8s.io/v1",
"/apis/authorization.k8s.io",
"/apis/authorization.k8s.io/v1",
"/apis/autoscaling",
it’s all JSON!
kubectl
goodnesskubectl explain pod
KIND: Pod
VERSION: v1
DESCRIPTION:
Pod is a collection of containers that can run on a host. This resource is
created by clients and scheduled onto hosts.
FIELDS:
apiVersion <string>
APIVersion defines the versioned schema of this representation of an
object. Servers should convert recognized schemas to the latest internal
value, and may reject unrecognized values. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
kind <string>
Kind is a string value representing the REST resource this object
represents. Servers may infer this from the endpoint the client submits
requests to. Cannot be updated. In CamelCase. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
keeping Kubernetes consistent for core built-in APIs. a strategic initiative in the CNCF in conjunction with ii.nz
the certification process requires each distribution to pass a set of tests and provide evidence and instructions for reproducing the data.
using some plumbing, write each Kubernetes api-server request to a database
apiVersion: audit.k8s.io/v1
kind: Policy
rules:
- level: RequestResponse
kubectl create namespace apisnoop
helm install -n apisnoop snoopdb charts/snoopdb
helm install -n apisnoop auditlogger charts/auditlogger
mock/exercise an API and prove change in API surface coverage
find things in the code base
example: https://issues.k8s.io/88302
after the endpoint and basic test are approved
...
ginkgo.It("resource should do the thing the resource does", func(ctx context.Context) {
list, err := clientset.SomeResource(f.Namespace.Name).List(ctx, resourcev1.ListOptions{})
gomega.Expect(err).To(BeNil(), "failure to list resource")
gomega.Expect(len(list.Items)).ToNot(gomega.Equal(0), "no items found")
})
...
this goes in the k/k/test/e2e
Kubernetes-native CI system built around and for the way that the community works.
the entrypoint changes
...
ginkgo.It("resource should do the thing the resource does", func(ctx context.Context) {
list, err := clientset.SomeResource(f.Namespace.Name).List(ctx, resourcev1.ListOptions{})
gomega.Expect(err).To(BeNil(), "failure to list resource")
gomega.Expect(len(list.Items)).ToNot(gomega.Equal(0), "no items found")
})
...
the entrypoint changes
...
framework.ConformanceIt("resource should do the thing the resource does", func(ctx context.Context) {
list, err := clientset.SomeResource(f.Namespace.Name).List(ctx, resourcev1.ListOptions{})
gomega.Expect(err).To(BeNil(), "failure to list resource")
gomega.Expect(len(list.Items)).ToNot(gomega.Equal(0), "no items found")
})
...
https://github.com/kubernetes/org/issues/1238
opening a ticket to kubernetes/org
it mostly comes down to
✨ be kind ✨
find your fit!
Kubernetes currently has ~23 special interest groups and 8 working groups, such as
and many many more!
see: https://www.kubernetes.dev/community/community-groups, https://github.com/kubernetes/community
each SIG has meetings on their different areas each week or so. meetings are structured around a document, often including fields like
join on Slack via https://slack.k8s.io
(end)