Skip to content

vedanta/k8s-samples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

k8s-samples

A curated set of small, focused Kubernetes example manifests and notes intended for learning and experimentation.

Each directory contains one or more minimal manifests that demonstrate a single Kubernetes concept. The repo is intentionally small and explicit so you can apply, inspect, and iterate on each example easily.

How to use

  • Review the YAML in a directory to understand the example.
  • Apply it with kubectl (prefer a disposable namespace or a local cluster like kind/minikube):
# create a namespace for experiments
kubectl create ns k8s-samples-explore

# apply a sample (example: deployments)
kubectl apply -f 015-deployments/my-deployment.yml -n k8s-samples-explore

# view resources
kubectl get all -n k8s-samples-explore

# cleanup
kubectl delete -f 015-deployments/my-deployment.yml -n k8s-samples-explore
kubectl delete ns k8s-samples-explore

General learning approach

  • Apply one example at a time.
  • Inspect resource status with kubectl describe and kubectl logs.
  • Make small edits (image, resource limits, probes) and re-apply to observe behavior.

Directory index and purpose

  • 000-kubeadm.md — Notes about using kubeadm to bootstrap a Kubernetes cluster. Useful if you're practicing cluster setup.

  • 005-configmaps/ — Examples showing ConfigMap usage:

    • sample-configmap.yml — create a ConfigMap from literal values.
    • config-volume.yaml and configmap-volume-reader.yml — mount a ConfigMap as a volume and read it from a pod.
    • readconfigmap-pod.yml — environment and volume examples for reading ConfigMap data.
  • 006-secrets/ — Secrets usage examples:

    • my-secret.yml — create a kubernetes Secret.
    • readsecret-pod.yml and secrets-volume-reader.yml — consume secrets as environment variables and mounted files.
  • 007-resource-requests/ — Demonstrates resource requests/limits:

    • pod-with-resources.yml, http-pod-with-resources.yml, big-request-pod.yml — try scheduling and behavior when resources are constrained.
  • 008-probes/ — Probes (liveness/readiness/startup):

    • liveness-pod.yml, liveness-pod-http.yml, readiness-pod.yml, startup-pod.yml — experiment with container health checks and how probe failures affect pod lifecycle.
  • 009-restart-policies/ — Pod restartPolicy variations:

    • always-pod.yml, onfailure-pod.yml, never-pod.yml — understand restart behaviors for containers that exit.
  • 010-multi-container-pods/ — Multi-container pod patterns:

    • multi-container-pod.yml — side-by-side containers
    • sidecar-pod.yml — sidecar pattern for logging/auxiliary tasks.
  • 011-init-containers/ — Init container example (init-pod.yml) to run setup tasks before the main container.

  • 012-secheduling/ — Scheduling primitives:

    • nodeselector-pod.yml, nodename-pod.yml — node selection and direct node assignment examples.
  • 013-daemonsets/ — DaemonSet examples (test-daemonset.yml, cleaner.yml) for running pods on each node.

  • 014-staticpod/ — Example static pod manifest (static-pod.yml) used when placing manifests on the node's kubelet-managed folder.

  • 015-deployments/ — Deployment example (my-deployment.yml) demonstrating rolling updates and replica management.

  • 016-dns/ — DNS troubleshooting example (dnstest.yml) to validate cluster DNS behavior.

  • 017-network-policies/ — NetworkPolicy examples to allow/deny traffic:

    • my-networkpolicy.yml, my-networkpolicy-allow.yml, network-deny-all.yml, np-nginx.yml, np-busybox.yml
    • more/ contains additional examples for namespace- and pod-selector-based rules and test pods.
  • 018-services/ — Service types and examples:

    • svc-clusterip.yml, svc-nodeport.yml, deployment-service-example.yml, pod-service-test.yml, web.yml — ClusterIP, NodePort and wiring a Service to a Deployment/Pod.
  • 019-ingress/ — Sample Ingress manifest (ingress-sample.yml) showing basic host/path routing (requires an Ingress controller to be present).

  • 020-storage-volumes/ — Storage examples:

    • sample-pv.yml, sample-pv-pod.yml, sample-pvc.yml — PV/PVC basics.
    • shared-volume-pod.yml, volume-pod.yml, localdisk-storageclass.yml — volume mounts and local storage class sample.
  • 021-cornjobs/ — CronJob sample (sample-cron.yml) showing scheduled jobs in Kubernetes.

  • 022-crds/ — CustomResourceDefinition examples (crd.yml) and a sample CustomType (my-ct.yml) to show extending the Kubernetes API.

  • 023-security-context/ — SecurityContext example (sc-ctx.yaml) demonstrating running pods with specific user/group or privilege restrictions.

  • 024-csr/ — Placeholder/TODO for CertificateSigningRequest examples.

  • 025-kustomize/ — Kustomize base example (in base/) demonstrating Kustomize overlays and simple resource composition.

  • 026-taints-tolerations/ — Taints and tolerations examples and notes (taint.md, affinity.md) plus sample pod YAMLs demonstrating scheduling under taints.

  • 027-image-pull-policy/ — Examples showing imagePullPolicy behaviors (pod-1.yaml, pod-2.yaml).

  • misc/ — Miscellaneous examples and playground YAMLs for topics like PodSecurity, liveness probes, replicasets, deployments with configmaps/env, and more. Useful as ad-hoc examples.

Helpful tips

  • Use a disposable cluster (kind/minikube/k3d) so you can freely apply and delete examples.
  • Use kubectl explain <resource> and kubectl get <resource> -o yaml to inspect live resources.
  • When experimenting with networking or storage, make sure your cluster environment supports those features (CNI plugin for NetworkPolicy, storage class for PVCs, Ingress controller for Ingress resources).

Contributing

  • If you add new examples, give them a focused purpose and include a short README inside the folder explaining the learning objective and any prerequisites.

License and attribution

  • This repo is intended for learning — adapt and reuse examples as needed.

License

This repository is licensed under the MIT License — see the LICENSE file for details.

About

tutorials for kubernetes concepts

Resources

License

Stars

Watchers

Forks

Packages

No packages published