Skip to content

Instantly share code, notes, and snippets.

@moinuddin14
Last active May 27, 2022 05:02
Show Gist options
  • Save moinuddin14/bcf070517cc2bee45e1721558258a5fc to your computer and use it in GitHub Desktop.
Save moinuddin14/bcf070517cc2bee45e1721558258a5fc to your computer and use it in GitHub Desktop.
This gist consists of examples for Kubernetes Labels, Selectors and Annotations
---
# Labels with prefix
apiVerion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: redpod
app.kubernetes.io/version: 1.24
# Labels without prefix
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
environment: prod
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
# Kubernetes Service Kind with Selectors
apiVersion: v1
kind: Service
metadata:
name: my-nginx
labels:
app: nginx
spec:
ports:
- port: 80
protocol: TCP
selector:
environment: prod
app: nginx
# Annotation Example
apiVersion: v1
kind: Pod
metadata:
name: annotations-demo
annotations:
imageregistry: "https://hub.docker.com/"
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment