2021-07-28 16:28:26 +00:00
|
|
|
---
|
2024-10-02 13:33:02 +00:00
|
|
|
apiVersion: v1
|
|
|
|
kind: ConfigMap
|
|
|
|
metadata:
|
|
|
|
name: nginx-config
|
|
|
|
data:
|
|
|
|
default.conf: |
|
|
|
|
server {
|
|
|
|
listen 80;
|
|
|
|
location /ip {
|
|
|
|
return 200 "$remote_addr\n";
|
|
|
|
}
|
|
|
|
# Default location block to serve the default "Welcome to nginx" page
|
|
|
|
location / {
|
|
|
|
root /usr/share/nginx/html;
|
|
|
|
index index.html;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
---
|
2021-07-28 16:28:26 +00:00
|
|
|
apiVersion: apps/v1
|
|
|
|
kind: Deployment
|
|
|
|
metadata:
|
|
|
|
name: test-loadbalancer
|
|
|
|
spec:
|
|
|
|
selector:
|
|
|
|
matchLabels:
|
|
|
|
k8s-app: nginx-app-loadbalancer
|
|
|
|
replicas: 2
|
|
|
|
template:
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
k8s-app: nginx-app-loadbalancer
|
|
|
|
spec:
|
|
|
|
containers:
|
|
|
|
- name: nginx
|
|
|
|
image: ranchertest/mytestcontainer
|
|
|
|
ports:
|
|
|
|
- containerPort: 80
|
2024-10-02 13:33:02 +00:00
|
|
|
volumeMounts:
|
|
|
|
- name: nginx-config-volume
|
|
|
|
mountPath: /etc/nginx/conf.d
|
|
|
|
volumes:
|
|
|
|
- name: nginx-config-volume
|
|
|
|
configMap:
|
|
|
|
name: nginx-config
|
2021-07-28 16:28:26 +00:00
|
|
|
---
|
|
|
|
apiVersion: v1
|
|
|
|
kind: Service
|
|
|
|
metadata:
|
|
|
|
name: nginx-loadbalancer-svc
|
|
|
|
labels:
|
|
|
|
k8s-app: nginx-app-loadbalancer
|
|
|
|
spec:
|
|
|
|
type: LoadBalancer
|
|
|
|
ports:
|
|
|
|
- port: 81
|
|
|
|
targetPort: 80
|
|
|
|
protocol: TCP
|
|
|
|
name: http
|
|
|
|
selector:
|
|
|
|
k8s-app: nginx-app-loadbalancer
|