Kubectl expose: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 5: | Line 5: | ||
=Overview= | =Overview= | ||
<code>expose</code> dynamically exposes a resource, which can be a pod, service, replicationcontroller, deployment or replicaset as a new service. If no service type is explicitly specified, [[Kubernetes_Service_Concepts#ClusterIP|ClusterIP]] is assumed. Specific service types | <code>expose</code> dynamically exposes a resource, which can be a pod, service, replicationcontroller, deployment or replicaset as a new service. If no service type is explicitly specified, [[Kubernetes_Service_Concepts#ClusterIP|ClusterIP]] is assumed. Specific service types ([[Kubernetes_Service_Concepts#NodePort|NodePort]], [[Kubernetes_Service_Concepts#LoadBalancer|LoadBalancer]], or [[Kubernetes_Service_Concepts#ExternalName|ExternalName]]) can be requested with <code>--type</code>. | ||
=Expose a Pod= | =Expose a Pod= |
Revision as of 00:09, 20 September 2020
Internal
Overview
expose
dynamically exposes a resource, which can be a pod, service, replicationcontroller, deployment or replicaset as a new service. If no service type is explicitly specified, ClusterIP is assumed. Specific service types (NodePort, LoadBalancer, or ExternalName) can be requested with --type
.
Expose a Pod
If a pod is used, the command reads the pod's labels and creates a service with a matching selector. By default, if no type is specified, ClusterIP is assumed.
kubectl [-n <namespace>] expose pod <pod-name> --port=<port> --target-port=<target-port> --name=<service-name> [--type=ClusterIP|NodePort|...]
kubectl expose pod httpd --port=9898 --target-port=80 --name=httpd-svc
Expose a Higher Level Controller
If a replication controller, deployment or replicaset are used, the command reads their selector and re-uses it for the service being created.
Expose a Service
TODO