# Kubeproxy ![image](./img/09_cluster_architecture_proxy.png "Kubelet") такс, ```bash cat < nginx-deployment.yml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: selector: matchLabels: app: nginx replicas: 3 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.21.3 ports: - containerPort: 80 EOF kubectl apply -f nginx-deployment.yml ``` ```bash kubectl get pod -o wide ``` ``` NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES hello-world 1/1 Running 0 109m 10.240.1.9 example-server nginx-deployment-5d9cbcf759-x4pk8 1/1 Running 0 84m 10.240.1.14 example-server ``` нам потрібна айпі адреса поду з деплойменту, в моєму випадку 10.240.1.10 запам'ятаємо її ```bash cat < rbac-create.yml kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: name: kubernetes-user-clusterrole rules: - apiGroups: [""] resources: ["nodes/proxy"] verbs: ["create"] --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: kubernetes-user-clusterrolebinding subjects: - kind: User name: kubernetes apiGroup: rbac.authorization.k8s.io roleRef: kind: ClusterRole name: kubernetes-user-clusterrole apiGroup: rbac.authorization.k8s.io EOF kubectl apply -f rbac-create.yml ``` ``` kubectl exec hello-world -- wget -O - 10.240.1.14 ``` ``` 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.

Connecting to 10.240.1.14 (10.240.1.14:80) writing to stdout - 100% |********************************| 615 0:00:00 ETA written to stdout ``` але це не прикольно, хочу звертатись до нджінк деплойменту і щоб воно там само працювало знаю що є сервіси - давай через них ```bash { cat < nginx-service.yml apiVersion: v1 kind: Service metadata: name: nginx-service spec: selector: app: nginx ports: - protocol: TCP port: 80 targetPort: 80 EOF kubectl apply -f nginx-service.yml } ``` ```bash kubectl get service ``` такс тепер беремо айпішнік того сервісу (у моєму випадку 10.32.0.95) і спробуємо повторити те саме ```bash kubectl exec hello-world -- wget -O - 10.32.0.95 ``` і нічого (тут можна згадати ще про ендпоінти і тп, але то може бути просто на довго) головна причина чого не працює на даному етапі - у нас не запущений ще 1 важливий компонент а саме куб проксі ```bash { cat > kube-proxy-csr.json < 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.

Connecting to 10.32.0.95 (10.32.0.95:80) writing to stdout - 100% |********************************| 615 0:00:00 ETA written to stdout ``` ух ти у нас все вийшло