Difference between revisions of "Networking in Kubernetes"
Jump to navigation
Jump to search
↑ https://linuxacademy.com/blog/linux-academy/top-ten-ways-not-to-sink-the-kubernetes-ship/?utm_source=intercom&utm_medium=email&utm_campaign=AprilNewsletter2019
Line 44: | Line 44: | ||
*Get the IP addresses of your pods: | *Get the IP addresses of your pods: | ||
− | < | + | <code>[[kubectl get pods]] -o wide</code> |
*Get the IP address of one of the nginx pods, then contact that nginx pod from the busybox pod using the nginx pod's IP address: | *Get the IP address of one of the nginx pods, then contact that nginx pod from the busybox pod using the nginx pod's IP address: | ||
− | < | + | <code>[[kubectl exec]] busybox -- curl $nginx_pod_ip</code> |
== See also == | == See also == | ||
* {{K8s}} | * {{K8s}} |
Latest revision as of 04:52, 3 May 2020
The Kubernetes networking model involves creating a virtual network across the whole cluster. This means that every pod on the cluster has a unique IP address, and can communicate with any other pod in the cluster, even if that other pod is running on a different node.
Kubernetes supports a variety of networking plugins that implements this model in various ways. One of the most popular and easy-to-use[1] is Flannel, although as of April 2019 do not support network policies.
- Create a deployment with two nginx pods:
cat << EOF | kubectl create -f - apiVersion: apps/v1 kind: Deployment metadata: name: nginx labels: app: nginx spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.15.4 ports: - containerPort: 80 EOF
- Create a busybox pod to use for testing:
cat << EOF | kubectl create -f - apiVersion: v1 kind: Pod metadata: name: busybox spec: containers: - name: busybox image: radial/busyboxplus:curl args: - sleep - "1000" EOF
- Get the IP addresses of your pods:
kubectl get pods -o wide
- Get the IP address of one of the nginx pods, then contact that nginx pod from the busybox pod using the nginx pod's IP address:
kubectl exec busybox -- curl $nginx_pod_ip
See also[edit]
- Kubernetes: distributions, tools, CKA, CKS, Kubernetes interfaces: CSI, CNI, installation, workloads, networking,
kubeadm
,Kubernetes API
, Kubernetes API Server,kubectl, kubeadm, kubelet, kube-proxy
, Cloud services: EKS, GKE, TKE, DKS, Helm, Kubernetes RBAC, Kubernetes deployments, Minikube, Rancher, OpenShift, Charmed Kubernetes, Ingress, Kubernetes scheduler, Kubernetes Finalizers, logging, Kubernetes operator, Orka,kind:
, Kubernetes namespaces, Kubernetes dashboard, Kubernetes Metrics Server, Field Selectors, CoreDNS, CRI, Kubernetes Topology Manager, Kubernetes governance: (SIG, KEP), Kustomize, controllers,ReadinessProbe, LivenessProbe
, KOPS, K9s, Kui, k3s, ImagePullBackOff, PDB, EndPoints, Kots, metadata, Karpenter, Replicated.com, Kubernetes Authenticating, Kubernetes timeline, Changelog/Versions, service accounts, Kubernetes Pod Lifecycle, Kubernetes Conformance Certified, Kubernetes backup, Kubernetes Pod Security Admission, tEKS, Kubernetes events, Kubernetes ports, Kubernetes policies, Connect, addons, DoKC, Kubernetes control plane, Kubernetes Federation, Kubernetes info, Kubetest2, Sidecar (Kubernetes)
Advertising: