Difference between revisions of "Kubernetes Loadbalancer Metallb"
Jump to navigation
Jump to search
(Created page with "https://kapuablog.wordpress.com/2020/02/15/k8s-and-metallb-a-local-non-cloud-loadbalancer/") |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
| + | # Install and Use | ||
https://kapuablog.wordpress.com/2020/02/15/k8s-and-metallb-a-local-non-cloud-loadbalancer/ | https://kapuablog.wordpress.com/2020/02/15/k8s-and-metallb-a-local-non-cloud-loadbalancer/ | ||
| + | |||
| + | # Troubleshooting | ||
| + | - https://metallb.universe.tf/configuration/troubleshooting/ | ||
| + | |||
| + | |||
| + | - Reserve range on dhcp server | ||
| + | |||
| + | ``` | ||
| + | microk8s.enable metallb | ||
| + | kubectl run --generator=run-pod/v1 mynginx --image nginx | ||
| + | kubectl expose pod nginx --port 80 --type LoadBalancer | ||
| + | kubectl get pods,services | ||
| + | curl -s -o - http://10.x.x.y | tail -4 | ||
| + | kubectl get svc nginx -o yaml | ||
| + | ``` | ||
| + | |||
| + | Double ports on same ip mynginx.yaml | ||
| + | ``` | ||
| + | apiVersion: v1 | ||
| + | kind: Service | ||
| + | metadata: | ||
| + | annotations: | ||
| + | # https://github.com/metallb/metallb/issues/121#issuecomment-367248030 | ||
| + | metallb.universe.tf/allow-shared-ip: shared-ip | ||
| + | labels: | ||
| + | run: nginx | ||
| + | name: nginx | ||
| + | namespace: default | ||
| + | spec: | ||
| + | externalTrafficPolicy: Cluster | ||
| + | loadBalancerIP: 10.x.x.y | ||
| + | type: LoadBalancer | ||
| + | ports: | ||
| + | - name: port-1 | ||
| + | port: 80 | ||
| + | protocol: TCP | ||
| + | targetPort: 80 | ||
| + | - name: port-2 | ||
| + | port: 443 | ||
| + | protocol: TCP | ||
| + | targetPort: 443 | ||
| + | selector: | ||
| + | run: nginx | ||
| + | sessionAffinity: None | ||
| + | ``` | ||
| + | |||
| + | ``` | ||
| + | kubectl delete svc mynginx | ||
| + | kubectl apply -f mynginx.yaml | ||
| + | kubectl get pods,services -o wide | ||
| + | ``` | ||
| + | You now could have https running on your nginx docker container. pretty cool. | ||
Latest revision as of 05:19, 13 February 2021
Install and Use
https://kapuablog.wordpress.com/2020/02/15/k8s-and-metallb-a-local-non-cloud-loadbalancer/
Troubleshooting
- https://metallb.universe.tf/configuration/troubleshooting/
- Reserve range on dhcp server
microk8s.enable metallb kubectl run --generator=run-pod/v1 mynginx --image nginx kubectl expose pod nginx --port 80 --type LoadBalancer kubectl get pods,services curl -s -o - http://10.x.x.y | tail -4 kubectl get svc nginx -o yaml
Double ports on same ip mynginx.yaml
apiVersion: v1
kind: Service
metadata:
annotations:
# https://github.com/metallb/metallb/issues/121#issuecomment-367248030
metallb.universe.tf/allow-shared-ip: shared-ip
labels:
run: nginx
name: nginx
namespace: default
spec:
externalTrafficPolicy: Cluster
loadBalancerIP: 10.x.x.y
type: LoadBalancer
ports:
- name: port-1
port: 80
protocol: TCP
targetPort: 80
- name: port-2
port: 443
protocol: TCP
targetPort: 443
selector:
run: nginx
sessionAffinity: None
kubectl delete svc mynginx kubectl apply -f mynginx.yaml kubectl get pods,services -o wide
You now could have https running on your nginx docker container. pretty cool.