{"id":1961,"date":"2024-06-11T07:11:30","date_gmt":"2024-06-11T07:11:30","guid":{"rendered":"https:\/\/www.nicktailor.com\/?p=1961"},"modified":"2025-06-11T07:13:26","modified_gmt":"2025-06-11T07:13:26","slug":"more-cheat-sheet-for-devops-engineers","status":"publish","type":"post","link":"https:\/\/nicktailor.com\/tech-blog\/more-cheat-sheet-for-devops-engineers\/","title":{"rendered":"More Cheat Sheet for DevOps Engineers"},"content":{"rendered":"\n\n<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\"\/>\n  <title>More Cheat Sheet for DevOps Engineers<\/title>\n  <style>\n    body {\n      font-family: Arial, sans-serif;\n      line-height: 1.6;\n      color: #333;\n      padding: 20px;\n      background-color: #f9f9f9;\n    }\n    h2, h3 {\n      color: #222;\n    }\n    pre {\n      background: #f4f4f4;\n      padding: 12px;\n      border-left: 4px solid #ccc;\n      overflow-x: auto;\n      white-space: pre-wrap;\n    }\n    code {\n      background: #eee;\n      padding: 2px 4px;\n      border-radius: 3px;\n      font-family: Consolas, monospace;\n    }\n    hr {\n      border: none;\n      border-top: 2px solid #ccc;\n      margin: 40px 0;\n    }\n  <\/style>\n<\/head>\n<body>\n\n\n<p>This guide is focused entirely on the most commonly used Kubernetes YAML examples and why you\u2019d use them in a production or staging environment. These YAML definitions act as the foundation for automating, scaling, and managing containerized workloads.<\/p>\n\n<hr \/>\n\n<h3>1. Pod YAML (Basic Unit of Execution)<\/h3>\n<p>Use this when you want to run a single container on the cluster.<\/p>\n<pre><code>apiVersion: v1\nkind: Pod\nmetadata:\n  name: simple-pod\nspec:\n  containers:\n  - name: nginx\n    image: nginx\n<\/code><\/pre>\n<p>This is the most basic unit in Kubernetes. Ideal for testing and debugging.<\/p>\n\n<hr \/>\n\n<h3>2. Deployment YAML (For Scaling and Updates)<\/h3>\n<p>Use deployments to manage stateless apps with rolling updates and replicas.<\/p>\n<pre><code>apiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  name: web-deployment\nspec:\n  replicas: 3\n  selector:\n    matchLabels:\n      app: web\n  template:\n    metadata:\n      labels:\n        app: web\n    spec:\n      containers:\n      - name: nginx\n        image: nginx:1.21\n<\/code><\/pre>\n\n<hr \/>\n\n<h3>3. Production-Ready Deployment Example<\/h3>\n<p>Use this to deploy a resilient application with health checks and resource limits.<\/p>\n<pre><code>apiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  name: production-app\n  labels:\n    app: myapp\nspec:\n  replicas: 4\n  selector:\n    matchLabels:\n      app: myapp\n  template:\n    metadata:\n      labels:\n        app: myapp\n    spec:\n      containers:\n      - name: myapp-container\n        image: myorg\/myapp:2.1.0\n        ports:\n        - containerPort: 80\n        livenessProbe:\n          httpGet:\n            path: \/healthz\n            port: 80\n          initialDelaySeconds: 15\n          periodSeconds: 20\n        readinessProbe:\n          httpGet:\n            path: \/ready\n            port: 80\n          initialDelaySeconds: 5\n          periodSeconds: 10\n        resources:\n          requests:\n            cpu: \"250m\"\n            memory: \"512Mi\"\n          limits:\n            cpu: \"500m\"\n            memory: \"1Gi\"\n<\/code><\/pre>\n\n<hr \/>\n\n<h3>4. Service YAML (Stable Networking Access)<\/h3>\n<pre><code>apiVersion: v1\nkind: Service\nmetadata:\n  name: web-service\nspec:\n  selector:\n    app: web\n  ports:\n  - port: 80\n    targetPort: 80\n  type: ClusterIP\n<\/code><\/pre>\n\n<hr \/>\n\n<h3>5. ConfigMap YAML (External Configuration)<\/h3>\n<pre><code>apiVersion: v1\nkind: ConfigMap\nmetadata:\n  name: app-config\ndata:\n  LOG_LEVEL: \"debug\"\n  FEATURE_FLAG: \"true\"\n<\/code><\/pre>\n\n<hr \/>\n\n<h3>6. Secret YAML (Sensitive Information)<\/h3>\n<pre><code>apiVersion: v1\nkind: Secret\nmetadata:\n  name: app-secret\nstringData:\n  password: supersecret123\n<\/code><\/pre>\n\n<hr \/>\n\n<h3>7. PersistentVolumeClaim YAML (For Storage)<\/h3>\n<pre><code>apiVersion: v1\nkind: PersistentVolumeClaim\nmetadata:\n  name: app-pvc\nspec:\n  accessModes:\n    - ReadWriteOnce\n  resources:\n    requests:\n      storage: 1Gi\n<\/code><\/pre>\n\n<hr \/>\n\n<h3>8. Job YAML (Run Once Tasks)<\/h3>\n<pre><code>apiVersion: batch\/v1\nkind: Job\nmetadata:\n  name: hello-job\nspec:\n  template:\n    spec:\n      containers:\n      - name: hello\n        image: busybox\n        command: [\"echo\", \"Hello World\"]\n      restartPolicy: Never\n<\/code><\/pre>\n\n<hr \/>\n\n<h3>9. CronJob YAML (Recurring Tasks)<\/h3>\n<pre><code>apiVersion: batch\/v1\nkind: CronJob\nmetadata:\n  name: scheduled-task\nspec:\n  schedule: \"*\/5 * * * *\"\n  jobTemplate:\n    spec:\n      template:\n        spec:\n          containers:\n          - name: task\n            image: busybox\n            args: [\"\/bin\/sh\", \"-c\", \"echo Scheduled Job\"]\n          restartPolicy: OnFailure\n<\/code><\/pre>\n\n<hr \/>\n\n<h3>10. Ingress YAML (Routing External Traffic)<\/h3>\n<pre><code>apiVersion: networking.k8s.io\/v1\nkind: Ingress\nmetadata:\n  name: web-ingress\n  annotations:\n    nginx.ingress.kubernetes.io\/rewrite-target: \/\nspec:\n  rules:\n  - host: myapp.example.com\n    http:\n      paths:\n      - path: \/\n        pathType: Prefix\n        backend:\n          service:\n            name: web-service\n            port:\n              number: 80\n<\/code><\/pre>\n\n<hr \/>\n\n<h3>11. NetworkPolicy YAML (Security Control)<\/h3>\n<pre><code>apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: allow-nginx\nspec:\n  podSelector:\n    matchLabels:\n      app: nginx\n  policyTypes:\n  - Ingress\n  ingress:\n  - from:\n    - podSelector:\n        matchLabels:\n          app: frontend\n<\/code><\/pre>\n\n<\/body>\n<\/html>\n\n","protected":false},"excerpt":{"rendered":"<p>More Cheat Sheet for DevOps Engineers This guide is focused entirely on the most commonly used Kubernetes YAML examples and why you\u2019d use them in a production or staging environment. These YAML definitions act as the foundation for automating, scaling, and managing containerized workloads. 1. Pod YAML (Basic Unit of Execution) Use this when you want to run a single<a href=\"https:\/\/nicktailor.com\/tech-blog\/more-cheat-sheet-for-devops-engineers\/\" class=\"read-more\">Read More &#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[145],"tags":[],"class_list":["post-1961","post","type-post","status-publish","format-standard","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts\/1961","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/comments?post=1961"}],"version-history":[{"count":1,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts\/1961\/revisions"}],"predecessor-version":[{"id":1962,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/posts\/1961\/revisions\/1962"}],"wp:attachment":[{"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/media?parent=1961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/categories?post=1961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nicktailor.com\/tech-blog\/wp-json\/wp\/v2\/tags?post=1961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}