Kubectl expose: Difference between revisions
Jump to navigation
Jump to search
Line 5: | Line 5: | ||
=Overview= | =Overview= | ||
<tt>expose</tt> dynamically exposes a resource | <tt>expose</tt> dynamically exposes a resource, which can be a pod, service, replicationcontroller, deployment or replicaset as a new service. | ||
If a pod is used, the command | |||
If a replication controller, deployment or replicset are used, the command | |||
The default service type is [[Kubernetes_Service_Concepts#ClusterIP|ClusterIP]], other type ([[Kubernetes_Service_Concepts#NodePort|NodePort]], [[Kubernetes_Service_Concepts#LoadBalancer|LoadBalancer]], or [[Kubernetes_Service_Concepts#ExternalName|ExternalName]]) can be specified with --type. | |||
kubectl [-n default] expose pod pg-0 --port=5432 --target-port=5432 --name=postgres --type=NodePort | kubectl [-n default] expose pod pg-0 --port=5432 --target-port=5432 --name=postgres --type=NodePort | ||
<font color=darkgray>TODO: I don't seem to see the service with kubectl get services, but attempting to connect to the database works.</font> | <font color=darkgray>TODO: I don't seem to see the service with kubectl get services, but attempting to connect to the database works.</font> |
Revision as of 23:52, 19 September 2020
Internal
Overview
expose dynamically exposes a resource, which can be a pod, service, replicationcontroller, deployment or replicaset as a new service.
If a pod is used, the command
If a replication controller, deployment or replicset are used, the command
The default service type is ClusterIP, other type (NodePort, LoadBalancer, or ExternalName) can be specified with --type.
kubectl [-n default] expose pod pg-0 --port=5432 --target-port=5432 --name=postgres --type=NodePort
TODO: I don't seem to see the service with kubectl get services, but attempting to connect to the database works.