Skip to content
CNPE · Chapter 20 of 22 Appendix A: Cheat Sheet

Appendix A: Cheat Sheet

Exam environment

Purpose Command
Check / switch context k config current-context · k config use-context <name>
Set the namespace for the shell k config set-context --current --namespace=<ns>
Generate YAML instead of typing k create deploy x --image=… --dry-run=client -o yaml > x.yaml
Look up a field (CRDs too) k explain rollout.spec.strategy.canary --recursive
All resources of an API group k api-resources --api-group=argoproj.io
Events of a namespace, newest at the bottom k get events --sort-by=.lastTimestamp
Check permissions k auth can-i <verb> <res> -n <ns> --as=<user> --as-group=<grp>
Check a subresource k auth can-i patch <res> --subresource=status …

Tenants (Day 1, 9)

k create ns team-x --dry-run=client -o yaml | k label --local -f - team=x tier=tenant -o yaml | k apply -f -
k -n team-x create rolebinding team-x-devs-edit --clusterrole=edit --group=team-x-devs
k -n team-x describe quota

A ResourceQuota on requests/limits requires values in every pod → LimitRange with default/defaultRequest.

Availability (Day 2)

k -n ns autoscale deploy x --cpu=60% --min=2 --max=5        # no replicas in the manifest!
k -n ns create pdb x --selector=app=x --max-unavailable=1
k drain <node> --ignore-daemonsets --delete-emptydir-data --timeout=300s
k uncordon <node>
k create priorityclass p --value=1000 --preemption-policy=Never

Topology spread with a control plane: nodeTaintsPolicy: Honor.

Argo CD (Day 3, 4)

Purpose Command
Status of all apps argocd app list · k -n argocd get applications
Check Git immediately argocd app get <app> --refresh
Difference argocd app diff <app>
End a hanging sync argocd app terminate-op <app>
Error message k -n argocd get application <app> -o jsonpath='{.status.conditions}'
  • Unknown = Git cannot be evaluated (path, repo, access) · Synced + Degraded = manifest broken
  • Rollback with automated: git revert, not argocd app rollback
  • Waves: argocd.argoproj.io/sync-wave: "-1" · Hooks: argocd.argoproj.io/hook: PreSync
  • An ApplicationSet without destination.namespace fails on project destinations

Argo Rollouts (Day 5, 10)

k argo rollouts get rollout x -n ns --no-color
k argo rollouts set image x -n ns c=image:tag
k argo rollouts promote x -n ns
k argo rollouts abort x -n ns
k -n ns get analysisrun

Analysis: Job (exit code) or Prometheus (successCondition: result[0] < 0.05).

Tekton (Day 6, 14)

k create -f lauf.yaml                    # PipelineRun with generateName
tkn pipelinerun logs -n ci --last -f
tkn pipelinerun list -n ci
tkn pipelinerun delete -n ci --keep 2 -f

Results: $(tasks.<task>.results.<name>) · Credentials: Secrets on the ServiceAccount (tekton.dev/git-0 annotation, dockerconfigjson).

Platform APIs (Day 7, 8)

  • CRD: openAPIV3Schema (enum, minimum, default), x-kubernetes-validations (CEL, oldSelf), subresources.status, additionalPrinterColumns
  • Permissions for your own types: ClusterRole with rbac.authorization.k8s.io/aggregate-to-edit: "true"
  • Switching versions: new one storage: true, old one deprecated, rewrite objects, clean up storedVersions
  • kubectl cache after a CRD change: rm -rf ~/.kube/cache/discovery
  • Crossplane: XRD (apiextensions.crossplane.io/v2) + Composition (pipeline, function-patch-and-transform); your own kinds need a ClusterRole with rbac.crossplane.io/aggregate-to-crossplane: "true"; readinessChecks: [{type: None}] for Secrets

Prometheus (Day 10–12)

sum by (status) (rate(http_requests_total[5m]))                    rate per status
increase(kube_pod_container_status_restarts_total[1h]) > 0         restarts
kube_deployment_status_replicas_available < 2                      missing replicas
quantile_over_time(0.95, rate(container_cpu_usage_seconds_total[5m])[1h:1m])   p95 CPU
max_over_time(container_memory_working_set_bytes[1h])              peak memory
count(ALERTS{alertstate="firing"})                                 firing alerts
  • A ServiceMonitor needs a named Service port and network access from monitoring
  • kubeadm: etcd/scheduler/controller manager/kube-proxy listen on 127.0.0.1
  • An AlertmanagerConfig in the team namespace automatically gets namespace="<ns>" as a filter

Kyverno 1.20 (Day 9, 13, 14)

Kind Core
ValidatingPolicy validationActions: [Audit] → [Deny]; validations[].expression (CEL)
MutatingPolicy patchType: ApplyConfiguration; for pods autogen.podControllers.controllers: []
GeneratingPolicy generator.Apply(ns, [objekte]), synchronize, generateExisting
ImageValidatingPolicy matchImageReferences, attestors.cosign.key, verifyImageSignatures
PolicyException policies.kyverno.io/v1, only in the permitted namespace, matchConditions

The classic ClusterPolicy is no longer executed. Reports: k get policyreport -A.

Supply chain (Day 14)

trivy image --severity HIGH,CRITICAL --exit-code 1 <image>
syft scan registry:<image> -o spdx-json=sbom.json
cosign sign --key cosign.key --signing-config signing-config.json --yes <image@digest>
cosign verify --key cosign.pub --insecure-ignore-tlog=true <image>

Digest in Git (kustomization.yaml → images[].digest), otherwise Kyverno and Argo CD fight each other.

Linkerd (Day 15)

linkerd check
k annotate ns x linkerd.io/inject=enabled          # then rollout restart
linkerd diagnostics proxy-metrics -n x deploy/y | grep tls=

Server (accessPolicy: deny) → HTTPRoute per path → AuthorizationPolicy with MeshTLSAuthentication (identity) or NetworkAuthentication (network).

Tools outside the course

The exam names further tools as examples. The concepts are the same:

In the course Alternative Difference in one sentence
Argo CD Flux Flux works with GitRepository + Kustomization/HelmRelease, without its own UI
Argo Rollouts Flagger Flagger controls normal Deployments via a mesh or ingress
Kyverno Gatekeeper/OPA Rules in Rego instead of CEL/YAML, templates + constraints
Linkerd Istio more features (Envoy proxy, gateways), more resources
Prometheus metrics OpenTelemetry, Jaeger Traces across service boundaries; collector as the central collection point

Contents

More