How to deploy docker container and do port mapping/forward using kubernetes YAML manifest
Please help me to convert the below docker Command to Kubernetes YAML file along with port mapping/forwarding to the docker container
# docker run -p 5775:5775/udp -p 6831:6831/udp -p 6832:6832/udp -p 5778:5778 -p 16686:16686 -p 14268:14268 jaegertracing/all-in-one:latest
I tried the configuration below:
enter image description here
But not getting any result.
I need experts here to tell me if the above deployment file is incorrect and if yes what could be the possible changes I can do here to get the results. I have tried several other combination's and I'm not getting any results.
Note: container gets deployed but the port mapping/forwarding is not working. That is where I'm stuck and seeking help .
If we specify a NodePort service, Kubernetes will allocate a port on every node. The chosen NodePort will be visible in the service spec after creation. Alternatively, one can specify a particular port to be used as NodePort in the spec while creating the service. If a specific NodePort is not specified, a port from a range configured on the Kubernetes cluster (default: 30000-32767) will be picked at random.
In Kubernetes you can define your ports using # port label. This label comes under port configuration in your deployment. According to the configurations you can simply define any number of ports you wish. Following example shows how to define two ports.
apiVersion: v1
kind: Service
Metadata:
name: my-service
Spec:
selector:
app: MyApp
Ports:
- name: http
protocol: TCP
port: 80
targetPort: 9376
- name: https
protocol: TCP
port: 443
targetPort: 9377
To do a port forward to local host run the following command.
kubectl port-forward <pod-name> <locahost-port>:<pod-port>
For more information refer to the links for Docker container port forwarding and node ports.