Skip to content

Instantly share code, notes, and snippets.

@res0nat0r
Last active November 13, 2024 21:09
Show Gist options
  • Save res0nat0r/fb675bb79fe8f769f7c3762254dac270 to your computer and use it in GitHub Desktop.
Save res0nat0r/fb675bb79fe8f769f7c3762254dac270 to your computer and use it in GitHub Desktop.
Internal / External Kubernetes Service Example
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: app
image: paulbouwer/hello-kubernetes:1.9
ports:
- name: web
containerPort: 8080
protocol: TCP
kind: Service
apiVersion: v1
metadata:
name: hello-world-internal
namespace: default
annotations:
service.beta.kubernetes.io/aws-load-balancer-internal: "true"
spec:
type: LoadBalancer
selector:
app: hello-world
ports:
- name: http
protocol: TCP
port: 80
targetPort: web
kind: Service
apiVersion: v1
metadata:
name: hello-world
namespace: default
spec:
type: LoadBalancer
selector:
app: hello-world
ports:
- name: http
protocol: TCP
port: 80
targetPort: web
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
labels:
app: test
spec:
replicas: 10
selector:
matchLabels:
app: test
template:
metadata:
labels:
app: test
spec:
nodeSelector:
kubernetes.io/hostname: ip-10-0-172-177.us-west-2.compute.internal
containers:
- name: test
image: alpine
command: ['sh', '-c', 'sleep 6666666']
resources:
requests:
memory: 1Gi
limits:
memory: 20Gi
---
apiVersion: v1
kind: Pod
metadata:
name: testing
spec:
nodeSelector:
kubernetes.io/hostname: ip-10-0-172-177.us-west-2.compute.internal
containers:
- name: testing
image: ubuntu
command: ['sh', '-c', 'sleep infinity']
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: hello-world
spec:
minAvailable: 1
selector:
matchLabels:
app: hello-world
apiVersion: apps/v1
kind: Deployment
metadata:
name: stefhen
spec:
replicas: 1
selector:
matchLabels:
app: stefhen
template:
metadata:
labels:
app: stefhen
spec:
containers:
- name: ubuntu
image: ubuntu
lifecycle:
postStart:
exec:
command: ["/bin/sh", "-c", "apt-get update -qq && apt-get install -y -qq curl wget httpie screen bind9-host"]
command: ["/bin/sh", "-c", "sleep infinity"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment