I have two simple applications that I have to deploy in Minikube on two different pods. The two applications must communicate via REST calls, so I need an IP address. How can I create a Minikube pod that I can reach locally via a hostname such as http://name:port without writing the IP address?
the Kubernetes-Approach would be adding an Service-Layer around the Pods (the instances) of your application. To do this, write a YAML-Spec like this:
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app: MyApp # << Replace with a matching Label
ports:
- protocol: TCP
port: 80
targetPort: # << Replace with a matching Port
After you applied your changes kubectl apply -f <FILENAME>
, you can access all services fulfilling the specified label-selector across all namespaces inside your cluster by calling this DNS-Name: my-service.<NAMESPACE>.svc