<p>it is possible to fix the ip and port somewhere in my yaml.
My application has 3 parts: a fronted with its respective balancer, a backend with its respective balancer and the database with statefulset and to persevere the volume, these 3 applications have their respective hpa rules.</p>

<p>I put the yaml of the backend if it is possible to set the ip and the port since I am working local and every so often I have to change the port or the ip.</p>

<p>backend.yml</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend
spec:
  replicas: 2
  selector:
    matchLabels:
      app: backend
  template:
    metadata:
      labels:
        app: backend
    spec:
      containers:
        - name: backend
          image: XXXXXXX
          command: ["/bin/sh"]
          args: ["-c", "node index.js"]
          ports:
            - containerPort: 4000
          imagePullPolicy: IfNotPresent
          env:
            - name: HOST_DB
              value: "172.17.0.3"
            - name: PORT_DB
              value: "31109"
          resources:
            requests:
              memory: "128Mi"
              cpu: "200m"
            limits:
              memory: "256Mi"
              cpu: "1000m"
          readinessProbe:
            httpGet:
              path: /
              port: 4000
            initialDelaySeconds: 5
            periodSeconds: 10
          livenessProbe:
            tcpSocket:
              port: 4000
            initialDelaySeconds: 15
            periodSeconds: 20

---
apiVersion: v1
kind: Service
metadata:
  name: backend
spec:
  selector:
    app: backend
  ports:
    - protocol: TCP
      port: 5000
      targetPort: 4000
      name: https
  type: LoadBalancer

---
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name: backend
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: backend
  minReplicas: 2
  maxReplicas: 10
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 50

</code></pre>

<p>the result image is this</p>

<p><a href="https://i.stack.imgur.com/B3PPt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B3PPt.png" alt="enter image description here"></a></p>

Silvio Peña
<p>The IP is anyway fixed to the single node's IP in case of minikube.You can hardcode the <code>NodePort</code> by specifying <code>nodePort</code> in the service. Without <code>nodePort</code> specified in the service kubernetes will assign a port from the range <code>30000-32767</code></p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: backend
spec:
  type: NodePort
  selector:
    app: backend
  ports:
    - protocol: TCP
      port: 5000
      targetPort: 4000
      name: https
      nodePort: 30007
</code></pre>

<p>Follow this <a href="https://kubernetes.io/docs/tasks/access-application-cluster/service-access-application-cluster/" rel="nofollow noreferrer">guide</a> to expose applications via <code>NodePort</code> type service in minikube. </p>
