$ kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.12.1/manifests/namespace.yaml
namespace/metallb-system created
$ kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.12.1/manifests/metallb.yaml
Warning: policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+
podsecuritypolicy.policy/controller created
podsecuritypolicy.policy/speaker created
serviceaccount/controller created
serviceaccount/speaker created
clusterrole.rbac.authorization.k8s.io/metallb-system:controller created
clusterrole.rbac.authorization.k8s.io/metallb-system:speaker created
role.rbac.authorization.k8s.io/config-watcher created
role.rbac.authorization.k8s.io/pod-lister created
role.rbac.authorization.k8s.io/controller created
clusterrolebinding.rbac.authorization.k8s.io/metallb-system:controller created
clusterrolebinding.rbac.authorization.k8s.io/metallb-system:speaker created
rolebinding.rbac.authorization.k8s.io/config-watcher created
rolebinding.rbac.authorization.k8s.io/pod-lister created
rolebinding.rbac.authorization.k8s.io/controller created
daemonset.apps/speaker created
deployment.apps/controller created
$ kubectl get all -n metallb-system
NAME READY STATUS RESTARTS AGE
pod/controller-57fd9c5bb-c8wfp 1/1 Running 0 69s
pod/speaker-dsq8s 1/1 Running 0 69s
pod/speaker-gn8gf 1/1 Running 0 69s
pod/speaker-l6kkc 1/1 Running 0 69s
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
daemonset.apps/speaker 3 3 3 3 3 kubernetes.io/os=linux 69s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/controller 1/1 1 1 69s
NAME DESIRED CURRENT READY AGE
replicaset.apps/controller-57fd9c5bb 1 1 1 69s
# vim metallb-config.yaml
---
apiVersion: v1
kind: ConfigMap
metadata:
namespace: metallb-system
name: config
data:
config: |
address-pools:
- name: default
protocol: layer2
addresses:
- 2804:694:3000:8000::50-2804:694:3000:8000::60
$ kubectl describe cm config -n metallb-system
Name: config
Namespace: metallb-system
Labels:
Annotations:
Data
====
config:
----
address-pools:
- name: default
protocol: layer2
addresses:
- 2804:694:3000:8000::50-2804:694:3000:8000::60
BinaryData
====
Events:
$ kubectl create deploy nginx --image=nginx
deployment.apps/nginx created
$ kubectl expose deploy nginx --cluster-ip='fd00::1' --type="LoadBalancer" --port 80 --target-port=80
service/nginx exposed
$ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/nginx-85b98978db-dczt5 1/1 Running 0 5m2s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 443/TCP 26m
service/nginx LoadBalancer fd00::1 2804:694:3000:8000::50 80:31832/TCP 5s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/nginx 1/1 1 1 5m2s
NAME DESIRED CURRENT READY AGE
replicaset.apps/nginx-85b98978db 1 1 1 5m2s
$ kubectl describe service nginx
Name: nginx
Namespace: default
Labels: app=nginx
Annotations:
Selector: app=nginx
Type: LoadBalancer
IP Family Policy: SingleStack
IP Families: IPv6
IP: fd00::1
IPs: fd00::1
LoadBalancer Ingress: 2804:694:3000:8000::50
Port: 80/TCP
TargetPort: 80/TCP
NodePort: 31832/TCP
Endpoints: [1100:200::1334:c75d:e2cb:7ec2]:80
Session Affinity: None
External Traffic Policy: Cluster
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal IPAllocated 37s metallb-controller Assigned IP ["2804:694:3000:8000::50"]
Normal nodeAssigned 37s metallb-speaker announcing from node "kube-worker-02.juntotelecom.com.br"
$ curl http://[2804:694:3000:8000::50]:80
Welcome to nginx!
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.
For online documentation and support please refer to
nginx.org.
Commercial support is available at
nginx.com.
Thank you for using nginx.
===== Ingress nginx =====
$ kubectl patch svc nginx -p '{"spec": {"ports": [{"port": 80}],"type": "NodePort"}}'
$ curl -O https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/baremetal/deploy.yaml
$ vim deploy.yaml
[...]
321 name: ingress-nginx-controller
322 namespace: ingress-nginx
323 spec:
324 clusterIP: fd00::1 <= ADICIONAR
325 ports:
326 - appProtocol: http
[...]
340 type: LoadBalancer <= Alterar de NodePort para LoadBalancer
---
[...]
351 name: ingress-nginx-controller-admission
352 namespace: ingress-nginx
353 spec:
354 clusterIP: fd00::2 <= ADICIONAR
355 ports:
356 - appProtocol: https
[...]
$ kubectl apply -f deploy.yaml
namespace/ingress-nginx created
serviceaccount/ingress-nginx created
serviceaccount/ingress-nginx-admission created
role.rbac.authorization.k8s.io/ingress-nginx created
role.rbac.authorization.k8s.io/ingress-nginx-admission created
clusterrole.rbac.authorization.k8s.io/ingress-nginx created
clusterrole.rbac.authorization.k8s.io/ingress-nginx-admission created
rolebinding.rbac.authorization.k8s.io/ingress-nginx created
rolebinding.rbac.authorization.k8s.io/ingress-nginx-admission created
clusterrolebinding.rbac.authorization.k8s.io/ingress-nginx created
clusterrolebinding.rbac.authorization.k8s.io/ingress-nginx-admission created
configmap/ingress-nginx-controller created
service/ingress-nginx-controller created
service/ingress-nginx-controller-admission created
deployment.apps/ingress-nginx-controller created
job.batch/ingress-nginx-admission-create created
job.batch/ingress-nginx-admission-patch created
ingressclass.networking.k8s.io/nginx created
validatingwebhookconfiguration.admissionregistration.k8s.io/ingress-nginx-admission created
$ kubectl get all -n ingress-nginx
NAME READY STATUS RESTARTS AGE
pod/ingress-nginx-admission-create-6nspk 0/1 Completed 0 57s
pod/ingress-nginx-admission-patch-f97d8 0/1 Completed 0 57s
pod/ingress-nginx-controller-7fc8d55869-5gdj4 1/1 Running 0 57s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/ingress-nginx-controller LoadBalancer fd00::1 2804:694:3000:8000::50 80:32549/TCP,443:31547/TCP 57s
service/ingress-nginx-controller-admission ClusterIP fd00::2 443/TCP 57s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/ingress-nginx-controller 1/1 1 1 57s
NAME DESIRED CURRENT READY AGE
replicaset.apps/ingress-nginx-controller-7fc8d55869 1 1 1 57s
NAME COMPLETIONS DURATION AGE
job.batch/ingress-nginx-admission-create 1/1 3s 57s
job.batch/ingress-nginx-admission-patch 1/1 3s 57s
$ kubectl create ingress nginx --class=nginx --rule=nginx.juntotelecom.com.br/*=nginx:80 --dry-run=client -o yaml > service.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
creationTimestamp: null
name: nginx
spec:
ingressClassName: nginx
rules:
- host: nginx.juntotelecom.com.br
http:
paths:
- backend:
service:
name: nginx
port:
number: 80
path: /
pathType: Prefix
status:
loadBalancer: {}
$ kubectl apply -f service.yaml
ingress.networking.k8s.io/nginx created
$ kubectl describe ingress nginx
Name: nginx
Labels:
Namespace: default
Address: 177.75.176.42
Default backend: default-http-backend:80 ()
Rules:
Host Path Backends
---- ---- --------
nginx.juntotelecom.com.br
/ nginx:80 ([1100:200::1334:c75d:e2cb:7ec2]:80)
Annotations:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Sync 24m (x2 over 25m) nginx-ingress-controller Scheduled for sync
$ kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
nginx nginx nginx.juntotelecom.com.br 177.75.176.42 80 94s
$ echo "2804:694:3000:8000::50 nginx.juntotelecom.com.br nginx" | sudo tee -a /etc/hosts
$ curl http://nginx.juntotelecom.com.br
Welcome to nginx!
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.
For online documentation and support please refer to
nginx.org.
Commercial support is available at
nginx.com.
Thank you for using nginx.