Created
February 2, 2023 21:30
-
-
Save rjchicago/1b74a3f1ca26512d420880cf3b73cdd2 to your computer and use it in GitHub Desktop.
Demo Nginx service health endpoint for MetlalLB in K8s.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: metallb-health | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: nginx-conf | |
namespace: metallb-health | |
data: | |
nginx.conf.template: | | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
server_name _; | |
location = /health { | |
access_log off; | |
add_header 'Content-Type' 'text/plain'; | |
add_header 'Hostname' '${HOSTNAME}'; | |
return 200 'OK'; | |
} | |
} | |
--- | |
apiVersion: apps/v1 | |
kind: DaemonSet | |
metadata: | |
name: metallb-health | |
namespace: metallb-health | |
spec: | |
selector: | |
matchLabels: | |
app: metallb-health | |
template: | |
metadata: | |
labels: | |
app: metallb-health | |
spec: | |
containers: | |
- name: metallb-health | |
image: nginx:1.23-alpine | |
ports: | |
- name: http | |
containerPort: 80 | |
volumeMounts: | |
- mountPath: /etc/nginx/templates | |
readOnly: true | |
name: nginx-conf | |
env: | |
- name: HOSTNAME | |
valueFrom: | |
fieldRef: | |
fieldPath: spec.nodeName | |
resources: | |
requests: | |
memory: "64Mi" | |
cpu: "250m" | |
limits: | |
memory: "128Mi" | |
cpu: "500m" | |
volumes: | |
- name: nginx-conf | |
configMap: | |
name: nginx-conf | |
items: | |
- key: nginx.conf.template | |
path: nginx.conf.template | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: metallb-health | |
namespace: metallb-health | |
annotations: | |
metallb.universe.tf/address-pool: ipaddresspool | |
metallb.universe.tf/allow-shared-ip: "metallb-ipaddresspool" | |
spec: | |
ports: | |
- port: 8082 | |
protocol: TCP | |
targetPort: 80 | |
selector: | |
app: metallb-health | |
type: LoadBalancer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment