Skip to content

Instantly share code, notes, and snippets.

@mcornea
Last active November 10, 2020 18:46
Show Gist options
  • Save mcornea/ece9d9eaf12cbfef85fecd272e53c38f to your computer and use it in GitHub Desktop.
Save mcornea/ece9d9eaf12cbfef85fecd272e53c38f to your computer and use it in GitHub Desktop.
httpd-pdb-anti-affinity
apiVersion: apps/v1
kind: Deployment
metadata:
name: httpd
namespace: test
spec:
replicas: 2
selector:
matchLabels:
app: httpd
template:
metadata:
labels:
app: httpd
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- httpd
topologyKey: "kubernetes.io/hostname"
containers:
- env:
image: registry.ocp-edge-cluster-0.qe.lab.redhat.com:5000/openshift/prometheus:latest
imagePullPolicy: IfNotPresent
name: httpd
ports:
- containerPort: 9090
protocol: TCP
volumeMounts:
- mountPath: /prometheus
name: httpd-volume-1
readinessProbe:
httpGet:
port: 9090
timeoutSeconds: 2
volumes:
- emptyDir: {}
name: httpd-volume-1
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: httpd-pdb
spec:
selector:
matchLabels:
app: httpd
minAvailable: 1
---
apiVersion: v1
kind: Service
metadata:
labels:
app: httpd
name: httpd
namespace: test
spec:
ports:
- name: 9090-tcp
port: 9090
protocol: TCP
targetPort: 9090
selector:
app: httpd
---
apiVersion: route.openshift.io/v1
kind: Route
metadata:
labels:
app: httpd
name: httpd
namespace: test
spec:
host: httpd-test.apps.ocp-edge-cluster-0.qe.lab.redhat.com
port:
targetPort: 9090-tcp
to:
kind: Service
name: httpd
weight: 100
wildcardPolicy: None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment