$30 off During Our Annual Pro Sale. View Details »

Kubernetes 102 - O Caminho das pedras - Parte 2

Kubernetes 102 - O Caminho das pedras - Parte 2

Services, o loadbalancer do kubernetes!

Avatar for Getup Cloud

Getup Cloud

August 23, 2018
Tweet

More Decks by Getup Cloud

Other Decks in Programming

Transcript

  1. @juniorjbn [email protected] KUBERNETES - 102 Kubernetes it's not a Big

    Deal. It's like the old infrastructure but without the old :D
  2. SVC Overview • Discovery • Balancing Remember • Readiness •

    Liveness • ExecAction • TCPSocketAction • HTTPGetAction SVC
  3. Service • Define ◦ Label Selector ◦ REST object kind:

    Service apiVersion: v1 metadata: name: my-service spec: selector: app: MyApp ports: - protocol: TCP port: 80 targetPort: 9376 $ kubectl -n demo run hello-cloud --image juniorjbn/php-demo:1 --port 8080 $ kubectl -n demo expose deployment hello-cloud --port=80 --target-port=8080 --type=LoadBalancer
  4. Service Multi-port • Define ◦ Label ◦ REST object ◦

    Name kind: Service apiVersion: v1 metadata: name: my-service spec: selector: app: MyApp ports: - name: http protocol: TCP port: 80 targetPort: 9376 - name: https protocol: TCP port: 443 targetPort: 9377
  5. HeadLess Service • What? ◦ External ◦ Manual kind: Endpoints

    apiVersion: v1 metadata: name: my-service subsets: - addresses: - ip: 1.2.3.4 ports: - port: 9376 kind: Service apiVersion: v1 metadata: name: my-service spec: ports: - protocol: TCP port: 80 targetPort: 9376
  6. Proxy-Mode Processos $ ps aux | grep kube-proxy $ journalctl

    $ tail -f /var/log/kube-proxy.log Regras $ Kubectl -n demo get pods -o wide $ gcloud compute ssh <node> --zone <zone> $ iptables-save | grep hello
  7. Service Type • ClusterIP ◦ Internal IP • NodePort ◦

    NodeIP:NodePort • LoadBalancer ◦ ProviderAPI • ExternalName ◦ CNAME • ExternalIPs kind: Service apiVersion: v1 metadata: name: my-service spec: selector: app: MyApp ports: - name: http protocol: TCP port: 80 targetPort: 9376 externalIPs: - 80.11.12.10
  8. Demo - Front + Back Colocar app no ar no

    cluster criado: • BACKEND • $ kubectl create -f https://k8s.io/examples/service/access/hello.yaml • $ kubectl create -f https://k8s.io/examples/service/access/hello-service.yaml • FRONTEND • $ kubectl create -f https://k8s.io/examples/service/access/frontend.yaml • $ kubectl get service frontend --watch