instruction: Create a Dockerfile for networking
output: ```dockerfile
  from a Pod
  Run Jobs
  Running Automated Tasks with a CronJob
  Coarse Parallel Processing Using a Work Queue
  Fine Parallel Processing Using a Work Queue
  Indexed Job for Parallel Processing with Static Work Assignment
  Job with Pod-to-Pod Communication
  Parallel Processing using Expansions
  Handling retriable and non-retriable pod failures with Pod failure policy
  Access Applications in a Cluster
  Deploy and Access the Kubernetes Dashboard
  Accessing Clusters
  Configure Access to Multiple Clusters
  Use Port Forwarding to Access Applications in a Cluster
  Use a Service to Access an Application in a Cluster
  Connect a Frontend to a Backend Using Services
  Create an External Load Balancer
  List All Container Images Running in a Cluster
  Set up Ingress on Minikube with the NGINX Ingress Controller
  Communicate Between Containers in the Same Pod Using a Shared Volume
  Configure DNS for a Cluster
  Access Services Running on Clusters
  Extend Kubernetes
  Configure the Aggregation Layer
  Use Custom Resources
  Extend the Kubernetes API with CustomResourceDefinitions
  Versions in CustomResourceDefinitions
  Set up an Extension API Server
  Configure Multiple Schedulers
  Use an HTTP Proxy to Access the Kubernetes API
  Use a SOCKS5 Proxy to Access the Kubernetes API
  Set up Konnectivity service
  TLS
  Issue a Certificate for a Kubernetes API Client Using A CertificateSigningRequest
  Configure Certificate Rotation for the Kubelet
  Manage TLS Certificates in a Cluster
  Manual Rotation of CA Certificates
  Manage Cluster Daemons
  Building a Basic DaemonSet
  Perform a Rolling Update on a DaemonSet
  Perform a Rollback on a DaemonSet
  Running Pods on Only Some Nodes
  Networking
  Adding entries to Pod /etc/hosts with HostAliases
  Extend Service IP Ranges
  Validate IPv4/IPv6 dual-stack
  Extend kubectl with plugins
  Manage HugePages
  Schedule GPUs
  Tutorials
  Hello Minikube
  Learn Kubernetes Basics
  Create a Cluster
  Using Minikube to Create a Cluster
  Deploy an App
  Using kubectl to Create a Deployment
  Explore Your App
  Viewing Pods and Nodes
  Expose Your App Publicly
  Using a Service to Expose Your App
  Scale Your App
  Running Multiple Instances of Your App
  Update Your App
  Performing a Rolling Update
  Configuration
  Updating Configuration via a ConfigMap
  Configuring Redis using a ConfigMap
  Adopting Sidecar Containers
  Security
  Apply Pod Security Standards at the Cluster Level
  Apply Pod Security Standards at the Namespace Level
  Restrict a Container's Access to Resources with AppArmor
  Restrict a Container's Syscalls with seccomp
  Stateless Applications
  Exposing an External IP Address to Access an Application in a Cluster
  Example: Deploying PHP Guestbook application with Redis
  Stateful Applications
  StatefulSet Basics
  Example: Deploying WordPress and MySQL with Persistent Volumes
  Example: Deploying Cassandra with a StatefulSet
  Running ZooKeeper, A Distributed System Coordinator
  Cluster Management
  Running Kubelet in Standalone Mode
  Namespaces Walkthrough
  Services
  Connecting Applications with Services
  Using Source IP
  Explore Termination Behavior for Pods And Their Endpoints
  Reference
  Glossary
  API Overview
  Kubernetes API Concepts
  Server-Side Apply
  Client Libraries
  Common Expression Language in Kubernetes
  Kubernetes Deprecation Policy
  Deprecated API Migration Guide
  Kubernetes API health endpoints
  API Access Control
  Authenticating
  Authenticating with Bootstrap Tokens
  Authorization
  Using RBAC Authorization
  Using Node Authorization
  Webhook Mode
  Using ABAC Authorization
  Admission Control
  Dynamic Admission Control
  Managing Service Accounts
  Certificates and Certificate Signing Requests
  Mapping PodSecurityPolicies to Pod Security Standards
  Kubelet authentication/authorization
  TLS bootstrapping
  Mutating Admission Policy
  Validating Admission Policy
  Well-Known Labels, Annotations and Taints
  Audit Annotations
  Kubernetes API
  Workload Resources
  Pod
  Binding
  PodTemplate
  ReplicationController
  ReplicaSet
  Deployment
  StatefulSet
  ControllerRevision
  DaemonSet
  Job
  CronJob
  HorizontalPodAutoscaler
  HorizontalPodAutoscaler
  PriorityClass
  PodSchedulingContext v1alpha3
  ResourceClaim v1beta1
  ResourceClaim v1alpha3
  ResourceClaimTemplate v1beta1
  ResourceClaimTemplate v1alpha3
  ResourceSlice v1beta1
  ResourceSlice v1alpha3
  Service Resources
  Service
  Endpoints
  EndpointSlice
  Ingress
  IngressClass
  Config and Storage Resources
  ConfigMap
  Secret
  CSIDriver
  CSINode
  CSIStorageCapacity
  PersistentVolumeClaim
  PersistentVolume
  StorageClass
  StorageVersionMigration v1alpha1
  Volume
  VolumeAttachment
  VolumeAttributesClass v1beta1
  Authentication Resources
  ServiceAccount
  TokenRequest
  TokenReview
  CertificateSigningRequest
  ClusterTrustBundle v1alpha1
  SelfSubjectReview
  Authorization Resources
  LocalSubjectAccessReview
  SelfSubjectAccessReview
  SelfSubjectRulesReview
  SubjectAccessReview
  ClusterRole
  ClusterRoleBinding
  Role
  RoleBinding
  Policy Resources
  FlowSchema
  LimitRange
  ResourceQuota
  NetworkPolicy
  PodDisruptionBudget
  PriorityLevelConfiguration
  ValidatingAdmissionPolicy
  ValidatingAdmissionPolicyBinding
  MutatingAdmissionPolicy v1alpha1
  MutatingAdmissionPolicyBinding v1alpha1
  Extend Resources
  CustomResourceDefinition
  DeviceClass v1alpha3
  DeviceClass v1beta1
  MutatingWebhookConfiguration
  ValidatingWebhookConfiguration
  Cluster Resources
  APIService
  ComponentStatus
  Event
  IPAddress v1beta1
  Lease
  LeaseCandidate v1alpha1
  LeaseCandidate v1alpha2
  Namespace
  Node
  RuntimeClass
  ServiceCIDR v1beta1
  Common Definitions
  DeleteOptions
  LabelSelector
  ListMeta
  LocalObjectReference
  NodeSelectorRequirement
  ObjectFieldSelector
  ObjectMeta
  ObjectReference
  Patch
  Quantity
  ResourceFieldSelector
  Status
  TypedLocalObjectReference
  Common Parameters
  Instrumentation
  Service Level Indicator Metrics
  CRI Pod & Container Metrics
  Node metrics data
  Kubernetes z-pages
  Kubernetes Metrics Reference
  Kubernetes Issues and Security
  Kubernetes Issue Tracker
  Kubernetes Security and Disclosure Information
  CVE feed
  Node Reference Information
  Kubelet Checkpoint API
  Linux Kernel Version Requirements
  Articles on dockershim Removal and on Using CRI-compatible Runtimes
  Node Labels Populated By The Kubelet
  Local Files And Paths Used By The Kubelet
  Kubelet Configuration Directory Merging
  Kubelet Device Manager API Versions
  Kubelet Systemd Watchdog
  Node Status
  Seccomp and Kubernetes
  Networking Reference
  Protocols for Services
  Ports and Protocols
  Virtual IPs and Service Proxies
  Setup tools
  Kubeadm
  kubeadm init
  kubeadm join
  kubeadm upgrade
  kubeadm upgrade phases
  kubeadm config
  kubeadm reset
  kubeadm token
  kubeadm version
  kubeadm alpha
  kubeadm certs
  kubeadm init phase
  kubeadm join phase
  kubeadm kubeconfig
  kubeadm reset phase
  Implementation details
  Command line tool (kubectl)
  Introduction to kubectl
  kubectl Quick Reference
  kubectl reference
  kubectl
  kubectl annotate
  kubectl api-resources
  kubectl api-versions
  kubectl apply
  kubectl apply edit-last-applied
  kubectl apply set-last-applied
  kubectl apply view-last-applied
  kubectl attach
  kubectl auth
  kubectl auth can-i
  kubectl auth reconcile
  kubectl auth whoami
  kubectl autoscale
  kubectl certificate
  kubectl certificate approve
  kubectl certificate deny
  kubectl cluster-info
  kubectl cluster-info dump
  kubectl completion
  kubectl config
  kubectl config current-context
  kubectl config delete-cluster
  kubectl config delete-context
  kubectl config delete-user
  kubectl config get-clusters
  kubectl config get-contexts
  kubectl config get-users
  kubectl config rename-context
  kubectl config set
  kubectl config set-cluster
  kubectl config set-context
  kubectl config set-credentials
  kubectl config unset
  kubectl config use-context
  kubectl config view
  kubectl cordon
  kubectl cp
  kubectl create
  kubectl create clusterrole
  kubectl create clusterrolebinding
  kubectl create configmap
  kubectl create cronjob
  kubectl create deployment
  kubectl create ingress
  kubectl create job
  kubectl create namespace
  kubectl create poddisruptionbudget
  kubectl create priorityclass
  kubectl create quota
  kubectl create role
  kubectl create rolebinding
  kubectl create secret
  kubectl create secret docker-registry
  kubectl create secret generic
  kubectl create secret tls
  kubectl create service
  kubectl create service clusterip
  kubectl create service externalname
  kubectl create service loadbalancer
  kubectl create service nodeport
  kubectl create serviceaccount
  kubectl create token
  kubectl debug
  kubectl delete
  kubectl describe
  kubectl diff
  kubectl drain
  kubectl edit
  kubectl events
  kubectl exec
  kubectl explain
  kubectl expose
  kubectl get
  kubectl kustomize
  kubectl label
  kubectl logs
  kubectl options
  kubectl patch
  kubectl plugin
  kubectl plugin list
  kubectl port-forward
  kubectl proxy
  kubectl replace
  kubectl rollout
  kubectl rollout history
  kubectl rollout pause
  kubectl rollout restart
  kubectl rollout resume
  kubectl rollout status
  kubectl rollout undo
  kubectl run
  kubectl scale
  kubectl set
  kubectl set env
  kubectl set image
  kubectl set resources
  kubectl set selector
  kubectl set serviceaccount
  kubectl set subject
  kubectl taint
  kubectl top
  kubectl top node
  kubectl top pod
  kubectl uncordon
  kubectl version
  kubectl wait
  kubectl Commands
  kubectl
  JSONPath Support
  kubectl for Docker Users
  kubectl Usage Conventions
  Component tools
  Feature Gates
  Feature Gates (removed)
  kubelet
  kube-apiserver
  kube-controller-manager
  kube-proxy
  kube-scheduler
  Debug cluster
  Flow control
  Configuration APIs
  Client Authentication (v1)
  Client Authentication (v1beta1)
  Event Rate Limit Configuration (v1alpha1)
  Image Policy API (v1alpha1)
  kube-apiserver Admission (v1)
  kube-apiserver Audit Configuration (v1)
  kube-apiserver Configuration (v1)
  kube-apiserver Configuration (v1alpha1)
  kube-apiserver Configuration (v1beta1)
  kube-controller-manager Configuration (v1alpha1)
  kube-proxy Configuration (v1alpha1)
  kube-scheduler Configuration (v1)
  kubeadm Configuration (v1beta3)
  kubeadm Configuration (v1beta4)
  kubeconfig (v1)
  Kubelet Configuration (v1)
  Kubelet Configuration (v1alpha1)
  Kubelet Configuration (v1beta1)
  Kubelet CredentialProvider (v1)
  WebhookAdmission Configuration (v1)
  External APIs
  Kubernetes Custom Metrics (v1beta2)
  Kubernetes External Metrics (v1beta1)
  Kubernetes Metrics (v1beta1)
  Scheduling
  Scheduler Configuration
  Scheduling Policies
  Other Tools
  Contribute
  Contribute to Kubernetes Documentation
  Contributing to Kubernetes blogs
  Submitting articles to Kubernetes blogs
  Blog guidelines
  Blog article mirroring
  Post-release communications
  Helping as a blog writing buddy
  Suggesting content improvements
  Contributing new content
  Opening a pull request
  Documenting for a release
  Case studies
  Reviewing changes
  Reviewing pull requests
  For approvers and reviewers
  Localizing Kubernetes documentation
  Participating in SIG Docs
  Roles and responsibilities
  Issue Wranglers
  PR wranglers
  Documentation style overview
  Content guide
  Style guide
  Diagram guide
  Writing a new topic
  Page content types
  Content organization
  Custom Hugo Shortcodes
  Updating Reference Documentation
  Quickstart
  Contributing to the Upstream Kubernetes Code
  Generating Reference Documentation for the Kubernetes API
  Generating Reference Documentation for kubectl Commands
  Generating Reference Documentation for Metrics
  Generating Reference Pages for Kubernetes Components and Tools
  
  Advanced contributing
  Viewing Site Analytics
  Docs smoke test pageKubernetes DocumentationConceptsServices, Load Balancing, and NetworkingEndpointSlicesYou are viewing documentation for Kubernetes version: v1.32Kubernetes v1.32 documentation is no longer actively maintained. The version you are currently viewing is a static snapshot. For up-to-date information, see the
  latest version.EndpointSlicesThe EndpointSlice API is the mechanism that Kubernetes uses to let your Service scale to handle large numbers of backends, and allows the cluster to update its list of healthy backends efficiently.FEATURE STATE:
  Kubernetes v1.21 [stable]Kubernetes' EndpointSlice API provides a way to track network endpoints
  within a Kubernetes cluster. EndpointSlices offer a more scalable and extensible
  alternative to Endpoints.EndpointSlice APIIn Kubernetes, an EndpointSlice contains references to a set of network
  endpoints. The control plane automatically creates EndpointSlices
  for any Kubernetes Service that has a selector specified. These EndpointSlices include
  references to all the Pods that match the Service selector. EndpointSlices group
  network endpoints together by unique combinations of protocol, port number, and
  Service name.
  The name of a EndpointSlice object must be a valid
  DNS subdomain name.As an example, here's a sample EndpointSlice object, that's owned by the example
  Kubernetes Service.apiVersion: discovery.k8s.io/v1
  kind: EndpointSlice
  metadata:
   name: example-abc
   labels:
   kubernetes.io/service-name: example
  addressType: IPv4
  ports:
   - name: http
   protocol: TCP
   port: 80
  endpoints:
   - addresses:
   - "10.1.2.3"
   conditions:
   ready: true
   hostname: pod-1
   nodeName: node-1
   zone: us-west2-a
  By default, the control plane creates and manages EndpointSlices to have no
  more than 100 endpoints each. You can configure this with the
  --max-endpoints-per-slice
  kube-controller-manager
  flag, up to a maximum of 1000.EndpointSlices can act as the source of truth for
  kube-proxy when it comes to
  how to route internal traffic.Address typesEndpointSlices support three address types:IPv4IPv6FQDN (Fully Qualified Domain Name)Each EndpointSlice object represents a specific IP address type. If you have
  a Service that is available via IPv4 and IPv6, there will be at least two
  EndpointSlice objects (one for IPv4, and one for IPv6).ConditionsThe EndpointSlice API stores conditions about endpoints that may be useful for consumers.
  The three conditions are ready, serving, and terminating.Readyready is a condition that maps to a Pod's Ready condition. A running Pod with the Ready
  condition set to True should have this EndpointSlice condition also set to true. For
  compatibility reasons, ready is NEVER true when a Pod is terminating. Consumers should refer
  to the serving condition to inspect the readiness of terminating Pods. The only exception to
  this rule is for Services with spec.publishNotReadyAddresses set to true. Endpoints for these
  Services will always have the ready condition set to true.ServingFEATURE STATE:
  Kubernetes v1.26 [stable]The serving condition is almost identical to the ready condition. The difference is that
  consumers of the EndpointSlice API should check the serving condition if they care about pod readiness while
  the pod is also terminating.Note:Although serving is almost identical to ready, it was added to prevent breaking the existing meaning
  of ready. It may be unexpected for existing clients if ready could be true for terminating
  endpoints, since historically terminating endpoints were never included in the Endpoints or
  EndpointSlice API to begin with. For this reason, ready is always false for terminating
  endpoints, and a new condition serving was added in v1.20 so that clients can track readiness
  for terminating pods independent of the existing semantics for ready.TerminatingFEATURE STATE:
  Kubernetes v1.22 [beta]Terminating is a condition that indicates whether an endpoint is terminating.
  For pods, this is any pod that has a deletion timestamp set.Topology informationEach endpoint within an EndpointSlice can contain relevant topology information.
  The topology information includes the location of the endpoint and information
  about the corresponding Node and zone. These are available in the following
  per endpoint fields on EndpointSlices:nodeName - The name of the Node this endpoint is on.zone - The zone this endpoint is in.Note:In the v1 API, the per endpoint topology was effectively removed in favor of
  the dedicated fields nodeName and zone.Setting arbitrary topology fields on the endpoint field of an EndpointSlice
  resource has been deprecated and is not supported in the v1 API.
  Instead, the v1 API supports setting individual nodeName and zone fields.
  These fields are automatically translated between API versions. For example, the
  value of the "topology.kubernetes.io/zone" key in the topology field in
  the v1beta1 API is accessible as the zone field in the v1 API.ManagementMost often, the control plane (specifically, the endpoint slice
  controller) creates and
  manages EndpointSlice objects. There are a variety of other use cases for
  EndpointSlices, such as service mesh implementations, that could result in other
  entities or controllers managing additional sets of EndpointSlices.To ensure that multiple entities can manage EndpointSlices without interfering
  with each other, Kubernetes defines the
  label
  endpointslice.kubernetes.io/managed-by, which indicates the entity managing
  an EndpointSlice.
  The endpoint slice controller sets endpointslice-controller.k8s.io as the value
  for this label on all EndpointSlices it manages. Other entities managing
  EndpointSlices should also set a unique value for this label.OwnershipIn most use cases, EndpointSlices are owned by the Service that the endpoint
  slice object tracks endpoints for. This ownership is indicated by an owner
  reference on each EndpointSlice as well as a kubernetes.io/service-name
  label that enables simple lookups of all EndpointSlices belonging to a Service.EndpointSlice mirroringIn some cases, applications create custom Endpoints resources. To ensure that
  these applications do not need to concurrently write to both Endpoints and
  EndpointSlice resources, the cluster's control plane mirrors most Endpoints
  resources to corresponding EndpointSlices.The control plane mirrors Endpoints resources unless:the Endpoints resource has a endpointslice.kubernetes.io/skip-mirror label
  set to true.the Endpoints resource has a control-plane.alpha.kubernetes.io/leader
  annotation.the corresponding Service resource does not exist.the corresponding Service resource has a non-nil selector.Individual Endpoints resources may translate into multiple EndpointSlices. This
  will occur if an Endpoints resource has multiple subsets or includes endpoints
  with multiple IP families (IPv4 and IPv6). A maximum of 1000 addresses per
  subset will be mirrored to EndpointSlices.Distribution of EndpointSlicesEach EndpointSlice has a set of ports that applies to all endpoints within the
  resource. When named ports are used for a Service, Pods may end up with
  different target port numbers for the same named port, requiring different
  EndpointSlices. This is similar to the logic behind how subsets are grouped
  with Endpoints.The control plane tries to fill EndpointSlices as full as possible, but does not
  actively rebalance them. The logic is fairly straightforward:Iterate through existing EndpointSlices, remove endpoints that are no longer
  desired and update matching endpoints that have changed.Iterate through EndpointSlices that have been modified in the first step and
  fill them up with any new endpoints needed.If there's still new endpoints left to add, try to fit them into a previously
  unchanged slice and/or create new ones.Importantly, the third step prioritizes limiting EndpointSlice updates over a
  perfectly full distribution of EndpointSlices. As an example, if there are 10
  new endpoints to add and 2 EndpointSlices with room for 5 more endpoints each,
  this approach will create a new EndpointSlice instead of filling up the 2
  existing EndpointSlices. In other words, a single EndpointSlice creation is
  preferable to multiple EndpointSlice updates.With kube-proxy running on each Node and watching EndpointSlices, every change
  to an EndpointSlice becomes relatively expensive since it will be transmitted to
  every Node in the cluster. This approach is intended to limit the number of
  changes that need to be sent to every Node, even if it may result with multiple
  EndpointSlices that are not full.In practice, this less than ideal distribution should be rare. Most changes
  processed by the EndpointSlice controller will be small enough to fit in an
  existing EndpointSlice, and if not, a new EndpointSlice is likely going to be
  necessary soon anyway. Rolling updates of Deployments also provide a natural
  repacking of EndpointSlices with all Pods and their corresponding endpoints
  getting replaced.Duplicate endpointsDue to the nature of EndpointSlice changes, endpoints may be represented in more
  than one EndpointSlice at the same time. This naturally occurs as changes to
  different EndpointSlice objects can arrive at the Kubernetes client watch / cache
  at different times.Note:Clients of the EndpointSlice API must iterate through all the existing EndpointSlices
  associated to a Service and build a complete list of unique network endpoints. It is
  important to mention that endpoints may be duplicated in different EndpointSlices.You can find a reference implementation for how to perform this endpoint aggregation
  and deduplication as part of the EndpointSliceCache code within kube-proxy.Comparison with EndpointsThe original Endpoints API provided a simple and straightforward way of
  tracking network endpoints in Kubernetes. As Kubernetes clusters
  and Services grew to handle
  more traffic and to send more traffic to more backend Pods, the
  limitations of that original API became more visible.
  Most notably, those included challenges with scaling to larger numbers of
  network endpoints.Since all network endpoints for a Service were stored in a single Endpoints
  object, those Endpoints objects could get quite large. For Services that stayed
  stable (the same set of endpoints over a long period of time) the impact was
  less noticeable; even then, some use cases of Kubernetes weren't well served.When a Service had a lot of backend endpoints and the workload was either
  scaling frequently, or rolling out new changes frequently, each update to
  the single Endpoints object for that Service meant a lot of traffic between
  Kubernetes cluster components (within the control plane, and also between
  nodes and the API server). This extra traffic also had a cost in terms of
  CPU use.With EndpointSlices, adding or removing a single Pod triggers the same number
  of updates to clients that are watching for changes, but the size of those
  update message is much smaller at large scale.EndpointSlices also enabled innovation around new features such dual-stack
  networking and topology-aware routing.What's nextFollow the Connecting Applications with Services tutorialRead the API reference for the EndpointSlice APIRead the API reference for the Endpoints APIFeedbackWas this page helpful?Yes
  NoThanks for the feedback. If you have a specific, answerable question about how to use Kubernetes, ask it on
  Stack Overflow.
  Open an issue in the GitHub Repository if you want to
  report a problem
  or
  suggest an improvement.Last modified March 14, 2024 at 2:28 PM PST: Add metadata to use mechanism for API reference links (c889d9b251) EndpointSlice API reference
    Create child page
   Create an issue
   Print entire sectionEndpointSlice APIAddress typesConditionsTopology informationManagementOwnershipEndpointSlice mirroringDistribution of EndpointSlicesDuplicate endpointsComparison with EndpointsWhat's next© 2025 The Kubernetes Authors | Documentation Distributed under CC BY 4.0© 2025 The Linux Foundation ®. ```