Skip to content
Kubernetes Yaml Templates
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
config k8s configmap Apr 15, 2019
podsecurity update doc Nov 21, 2018
quota update doc Nov 9, 2018
rbac update rbac Apr 18, 2019
service configmap Apr 8, 2019
volume nfs volume Apr 16, 2019
.gitignore improve yaml templates Sep 14, 2018
kubernetes-yaml-templates.pdf k8s configmap Apr 15, 2019

1 Kubernetes Yaml Templates


PRs Welcome

File me Issues or star this repo.

1.1 Pod

pod/pod-dummy.yamlStart a dummy pod with a dead sleep loop
pod/pod-nginx.yamlStart a pod of sample app(nginx)
pod/pod-initcontainer-sysctl.yamlUse initContainer to run sysctl, when starting a Pod
pod/pod-healthcheck-nginx.yamlStart pod with tcp and http healthcheck
pod/pod-secrets.yamlPod use secrets as either volumes or environment variables
pod/pod-gitclone.yamlPod: use initContainer as sidecar to web host a git repo
pod/pod-hostaliases.yamlPod: add alias to /etc/hosts
pod/pod-serviceaccount.yamlStart pod with serviceaccount, instead of default serviceaccount
pod/pod-handlers.yamlPod’s events whenever it get started or stoppped
ReferenceLink: kubectl cheatsheet

1.2 Volume

volume/volume-manual-pv.yamlCreate pv first, then pvc
volume/volume-mount-localpath.yamlMount a local folder to pods
volume/volume-emptydir.yamlCreate a empty folder, then mount to pods
volume/volume-ebs.yamlMount EBS volume to pod running in amazon instance with the same AZ
volume/volume-nfs.yamlCreate nfs pv
volume/volume-gcePersistentDisk.yamlMount GCE disk to pod running in amazon instance with the same AZ
volume/volume-digitalocean.yamlCreate DigitalOcean volume for your kubernetes cluster in DigitalOcean
ReferenceLink: kubectl cheatsheet, Link: volumes examples

1.3 Service

service/service-loadbalancer.yamlService: loadbalancer
service/service-nodeport.yamlService: nodeport
service/service-ingress.yamlService: ingress
service/service-clusterip-nginx.yamlService: nginx with clusterip
service/service-cassandra.yamlService: cassandra
ReferenceLink: kubectl cheatsheet

1.4 Configmap/Envs

config/pod-configmap.yamlCreate configmap from file, then use it as a pod volume
config/pod-environment-var.yamlStart a pod passing environment variables
config/pod-env-metada.yamlExpose metadata to pods
config/configmap-plaintext.yamlDefine configmap with plain text

1.5 Security - RBAC

rbac/serviceaccount-default.yamlServiceaccount: basic usage
rbac/rbac-default.yamlServiceaccount: concret example
ReferenceLink: kubectl cheatsheet

1.6 Security - PodSecurityPolicy

podsecurity/securitycontext-user.yamlConfigure userid, at both pod and container levels
podsecurity/podsecurity-privileged.yamlCreate pod security with privileged access
podsecurity/podsecurity-restricted.yamlCreate pod security with restricted access, then apply it later
podsecurity/podsecurity-enforce.yamlEnforce policy security by defining role and cluster role
podsecurity/podsecurity-advanced.yamlA more complicated definition of pod security policy
podsecurity/podsecurity-example.yamlA full example with everything included
LinksLink: kubectl cheatsheet

1.7 Security - NetworkPolicy

networksecurity/networksecurity-denyall-ingress.yamlAllow all ingress
networksecurity/networksecurity-allowall-ingress.yamlDeny all ingress
networksecurity/networksecurity-denyall.yamlDeny all ingress and egress
networksecurity/networksecurity-pod.yamlWhitelist traffic control
networksecurity/networksecurity-complicated.yamlA comprehensive network policy example
networksecurity/networksecurity-port.yamlAllow TCP 443 from one namespace
networksecurity/networksecurity-deny-othernamespaces.yamlDeny all ingress traffic from other namespaces
networksecurity/networksecurity-denyegress-exceptdns.yamlDeny all egress traffic except DNS
ReferenceLink: kubectl cheatsheet, GitHub: kubernetes-network-policy-recipes

1.8 Quota & Limits

quota/limitrange-pvc-size.yamlLimitRange: PVC size
quota/limitrange-pvc-cumulative-size.yamlResourceQuota: pvc count and storage size
quota/limitrange-mem-size.yamlLimitRange: Pod ram usage. Then apply it to namespace
ReferenceLink: kubectl cheatsheet

1.9 Deployment

deployment/deployment-nginx.yamlDeploy nginx with 2 replicas
deployment/deployment-mysql.yamlDeploy mysql
ReferenceLink: kubectl cheatsheet

1.10 Statefulset

statefulset/statefulset-nginx.yamlStatefulset: nginx
statefulset/statefulset-single-mysqlStatefulset: mysql
statefulset/statefulset-replicated-cassandra.yamlStatefulset: single cassandra
statefulset/statefulset-replicated-mysqlStatefulset: cassandra with replicas
ReferenceLink: kubectl cheatsheet

1.11 General

namespace/ns-dummy.yamlCreate a dummy namespace

1.12 Jobs & CronJob

job/job-affinity.yamlDeploy a job with node affinity

1.13 Related Tools

GitHub: kubernetes-sigs/kustomizeCustomization of kubernetes YAML configurations

1.14 More Resources

License: Code is licensed under MIT License.

You can’t perform that action at this time.