🌟
z's
  • Hello
  • Cheatsheets
    • 🍂Docker Compose Services
    • 🌿Git
    • ▶️ Golang
      • Gotchas
    • ⛑️Helm
    • ☸️ Kubernetes Management
    • ☸️ Kubernetes Resources
    • ☸️Kubernetes Snippets
    • 🔨Tools Quicklinks
    • Tools and Useful Stuff
    • 🟠Using Ubuntu
    • Reference/Template Dockerfiles
  • How-Tos
    • Use Ubuntu
    • Use VSCode
    • Use AWS
    • Use Git
    • Use GPG keys
    • Use Digital Ocean
  • About Me
    • Want to work with me?
    • How to work with me
  • Useful Tools
    • Collaboration
      • Miro
    • Documentation
      • Gitbook
      • Notion
  • On Growing People
    • Ontological Coaching
    • Organization Development (OD)
    • Speech Acts
    • Books & Other Resources
  • On Creating Software
    • Product
    • Design
    • Development Environments
      • Introduction
      • Visual Studio Code/Codium
      • Public Key Infrastructure (PKI) Setup & Usage
    • Patterns
      • API Authentication
      • User Authentication
    • Languages/Formats
      • JavaScript
      • Golang
      • HTML
      • CSS
      • SQL
      • JSON
      • YAML
    • Code Logistics
    • Data Persistence
      • Cassandra
    • Software Architecture
    • System Observability
    • Cool Tools
    • Kubernetes
      • Resource Cheatsheet
      • 1/ Kubernetes in 5 Minutes
      • 2/ Setting up Kubernetes locally
      • 3/ Handling long-running workloads
      • 4/ Handling run-once workloads
Powered by GitBook
On this page
  • CronJob
  • Deployment
  • Job
  • Pod
  • Service

Was this helpful?

  1. On Creating Software
  2. Kubernetes

Resource Cheatsheet

CronJob

# replace __application__ with your application name
# replace __docker__/__image__:__tag__ with your image
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: __application__
spec:
  schedule: "*/1 * * * *"
  jobTemplate:
    spec:
      successfulJobsHistoryLimit: 3
      failedJobsHistoryLimit: 5
      template:
        spec:
          containers:
          - name: hello
            image: __docker__/__image__:__tag__
            imagePullPolicy: IfNotPresent
            args:
            - /bin/sh
            - -c
            - date; echo "Hello!"
          restartPolicy: OnFailure

Deployment

# replace __application__ with your application name
# replace __docker__/__image__:__tag__ with your image
apiVersion: apps/v1
kind: Deployment
metadata:
  name: __application__
  labels:
    app: __application__
spec:
  replicas: 1
  selector:
    matchLabels:
      app: __application__
  template:
    metadata:
      labels:
        app: __application__
    spec:
      containers:
      - name: __application__
        image: __docker__/__path__:__tag__
        imagePullPolicy: Never
        ports:
        - name: http
          containerPort: 8000
          protocol: TCP
        resources:
          limits:
            memory: 25Mi
            cpu: 75m
          requests:
            memory: 20Mi
            cpu: 50m

Job

# replace __application__ with your job name
# replace __docker__/__image__:__tag__ with your image
apiVersion: batch/v1
kind: Job
metadata:
  name: __application__
spec:
  template:
    # This is the pod template
    spec:
      containers:
      - name: hello
        image: __docker__/__image__:__tag__ 
        command: ['sh', '-c', 'while :; do echo "Hello!"; sleep 5; done']
      restartPolicy: OnFailure

Pod

# replace __application__ with your job name
# replace __docker__/__image__:__tag__ with your image
apiVersion: v1
kind: Pod
metadata:
  name: __application__
  labels:
    app: __application__
spec:
  containers:
    - name: web
      image: __docker__/__image__:__tag__ 
      command: ['sh', '-c', 'echo "Hello!" && sleep 3600']
      ports:
        - name: web
          containerPort: 80
          protocol: TCP

Service

# replace __application__ with your service name
apiVersion: v1
kind: Service
metadata:
  name: __application__
spec:
  selector:
    app: __application__
  ports:
    - protocol: TCP
      port: 8000
      targetPort: 8000
PreviousKubernetesNext1/ Kubernetes in 5 Minutes

Last updated 4 years ago

Was this helpful?