<p>I am trying to install velero and minio for my k8s cluster. I have one master and 2 worker nodes.
I have issue with NodePort service.</p>
<p>Overall pods are working and Node Port service is also running but when I try to access the minio Dashboard from browser It change Port number. I thought that issue is with my service so I also created another <a href="https://stackoverflow.com/questions/75234024/why-my-nodeport-service-change-its-port-number/75234616?noredirect=1#comment132760590_75234616">question</a> for that.</p>
<p>Actual problem is with Console port.</p>
<p>When I run <code>kubectl logs minio-8649b94fb5-8cr2k  -n velero</code> I see this information .</p>
<pre><code>WARNING: MINIO_ACCESS_KEY and MINIO_SECRET_KEY are deprecated.
         Please use MINIO_ROOT_USER and MINIO_ROOT_PASSWORD
Formatting 1st pool, 1 set(s), 1 drives per set.
WARNING: Host local has more than 0 drives of set. A host failure will result in data becoming unavailable.
MinIO Object Storage Server
Copyright: 2015-2023 MinIO, Inc.
License: GNU AGPLv3 &lt;https://www.gnu.org/licenses/agpl-3.0.html&gt;
Version: RELEASE.2023-01-25T00-19-54Z (go1.19.4 linux/amd64)

Status:         1 Online, 0 Offline.
API: http://10.244.2.136:9000  http://127.0.0.1:9000
Console: http://10.244.2.136:37269 http://127.0.0.1:37269

Documentation: https://min.io/docs/minio/linux/index.html
Warning: The standard parity is set to 0. This can lead to data loss.
</code></pre>
<p>The port number of</p>
<p><code>Console: http://10.244.2.136:37269 http://127.0.0.1:37269</code>   is different than the port of Node Port service.</p>
<p>This is my NodePort Service</p>
<pre><code>master-k8s@masterk8s-virtual-machine:~/velero-v1.2.0-darwin-amd64$ kubectl get svc -n velero
NAME    TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
minio   NodePort   10.97.197.54   &lt;none&gt;        9000:30480/TCP   82m
</code></pre>
<p>When I search the URL in browser with service port number it convert to console port and I am not able to access my application.</p>
<p><strong>What I have done to fix this:</strong></p>
<ol>
<li>I try to use Load balancer services and still not able to access the Application.</li>
<li>I also assign the NodePort in service.yaml file It stop changing the port but I am not able to access the Application.</li>
<li>I change the Ports in application and service still the same issue.</li>
<li>Log have noting but this information.</li>
<li>I try to install minio directly on my Ubuntu VM and it was successful.</li>
</ol>
<p><strong>What do I want:</strong></p>
<p>I have done everything I could do. I don't find any issue like that or any information related to this topic. Any advice will be very help to fix this issue. How can I change the port of console or make it sync with service port?</p>
<p><strong>Updated yaml</strong></p>
<pre><code>apiVersion: v1
kind: Namespace
metadata:
  name: velero

---
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: minio
  name: minio
  labels:
    component: minio
spec:
  strategy:
    type: Recreate
  selector:
    matchLabels:
      component: minio
  template:
    metadata:
      labels:
        component: minio
    spec:
      volumes:
      - name: storage
        emptyDir: {}
      - name: config
        emptyDir: {}
      containers:
      - name: minio
        image: minio/minio:latest
        imagePullPolicy: IfNotPresent
        args:
        - server
        - /storage
        - --console-address=:9090
        - --config-dir=/config
        env:
        - name: MINIO_ACCESS_KEY
          value: &quot;minio&quot;
        - name: MINIO_SECRET_KEY
          value: &quot;minio123&quot;
        ports:
        - containerPort: 9000
          name: api
        - containerPort: 9090
          name: console
        volumeMounts:
        - name: storage
          mountPath: &quot;/storage&quot;
        - name: config
          mountPath: &quot;/config&quot;

---
apiVersion: v1
kind: Service
metadata:
  namespace: minio
  name: minio-service
  labels:
    component: minio
spec:
  # ClusterIP is recommended for production environments.
  # Change to NodePort if needed per documentation,
  # but only if you run Minio in a test/trial environment, for example with Minikube.
  type: LoadBalancer
  ports:
    - port: 9000
      targetPort: 9000
      protocol: TCP
  selector:
    component: minio

---
apiVersion: batch/v1
kind: Job
metadata:
  namespace: minio
  name: minio-setup
  labels:
    component: minio
spec:
  template:
    metadata:
      name: minio-setup
    spec:
      restartPolicy: OnFailure
      volumes:
      - name: config
        emptyDir: {}
      containers:
      - name: mc
        image: minio/mc:latest
        imagePullPolicy: IfNotPresent
        command:
        - /bin/sh
        - -c
        - &quot;mc --config-dir=/config config host add velero http://minio:9000 minio minio123 &amp;&amp; mc --config-dir=/config mb -p velero/velero&quot;
        volumeMounts:
        - name: config
          mountPath: &quot;/config&quot;
      
</code></pre>

tauqeerahmad24
<p>We need to tell Minio to use a static console port. We can do that by providing the <code>--console-address</code> argument to the <code>minio server</code> command.  Here's an example Deployment that I have used to run Minio locally:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: minio
  name: minio
  namespace: minio
spec:
  replicas: 1
  selector:
    matchLabels:
      app: minio
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: minio
    spec:
      containers:
      - command:
        - minio
        - server
        - /data
        - --console-address=:9090
        envFrom:
        - secretRef:
            name: minio-creds-9d9kmkc4m4
        image: quay.io/minio/minio:latest
        name: minio
        ports:
        - containerPort: 9000
          name: api
        - containerPort: 9090
          name: console
        volumeMounts:
        - mountPath: /data
          name: minio-data
      volumes:
      - name: minio-data
        persistentVolumeClaim:
          claimName: minio-data

</code></pre>
<p>This runs <code>minio server /data --console-address=:9090</code>; when Minio starts up, we see in the logs:</p>
<pre><code>Status:         1 Online, 0 Offline.
API: http://10.244.0.11:9000  http://127.0.0.1:9000
Console: http://10.244.0.11:9090 http://127.0.0.1:9090
</code></pre>
<p>Now that we have a static port, we can set up the NodePort service you want:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  labels:
    app: minio
  name: minio
  namespace: minio
spec:
  ports:
  - name: api
    nodePort: 30900
    port: 9000
    protocol: TCP
    targetPort: api
  - name: console
    nodePort: 30990
    port: 9090
    protocol: TCP
    targetPort: console
  selector:
    app: minio
  type: NodePort

</code></pre>
<p>This exposes the API on port 30900 and the console on port 30990.</p>
<hr />
<p>You can find my complete test including manifests and deployment instructions at <a href="https://github.com/larsks/k8s-example-minio/" rel="nofollow noreferrer">https://github.com/larsks/k8s-example-minio/</a>.</p>
