<p>I've deployed a MinIO server on Kubernetes with cdk8s, used <code>minio1</code> as serviceId and exposed port 9000.</p>
<p>My expectations were that I could access it using <code>http://minio1:9000</code>, but my MinIO server is unreachable from both Prometheus and other instances in my namespace (Loki, Mimir etc...). Is there a specific configuration I missed to enable access within the network? The server starts without error, so it sounds a networking issue.</p>
<p>I'm starting the server this way:</p>
<pre><code>      command: [&quot;minio&quot;],
      args: [
        &quot;server&quot;,
        &quot;/data&quot;,
        &quot;--address&quot;,
        `:9000`,
        &quot;--console-address&quot;,
        `:9001`,
      ],
</code></pre>
<p>Patched the K8S configuration to expose both 9000 and 9001</p>
<pre class="lang-js prettyprint-override"><code>    const d = ApiObject.of(minioDeployment);
    
    //Create the empty port list
    d.addJsonPatch(JsonPatch.add(&quot;/spec/template/spec/containers/0/ports&quot;, []));
    
    //add port for console
    d.addJsonPatch(
      JsonPatch.add(&quot;/spec/template/spec/containers/0/ports/0&quot;, {
        name: &quot;console&quot;,
        containerPort: 9001,
      })
    );
    // add port for bucket
    d.addJsonPatch(
      JsonPatch.replace(&quot;/spec/template/spec/containers/0/ports/1&quot;, {
        name: &quot;bucket&quot;,
        containerPort: 9000,
      })
    );
</code></pre>
<p>Can it be related to the multi-port configuration? Or is there a way to explicitly define the hostname as service id to make it accessible in the Kubernetes namespace?</p>
<p>Here's my service definition generated by cdk8s:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    use-default-egress-policy: &quot;true&quot;
  name: minio1
  namespace: ns-monitoring
spec:
  minReadySeconds: 0
  progressDeadlineSeconds: 600
  replicas: 1
  selector:
    matchExpressions: []
    matchLabels:
      cdk8s.deployment: monitoring-stack-minio1-minio1-deployment-c8e6c44f
  strategy:
    rollingUpdate:
      maxSurge: 50%
      maxUnavailable: 50%
    type: RollingUpdate
  template:
    metadata:
      labels:
        cdk8s.deployment: monitoring-stack-minio1-minio1-deployment-c8e6c44f
    spec:
      automountServiceAccountToken: true
      containers:
        - args:
            - server
            - /data/minio/
            - --address
            - :9000
            - --console-address
            - :9001
          command:
            - minio
          env:
            - name: MINIO_ROOT_USER
              value: userminio
            - name: MINIO_ROOT_PASSWORD
              value: XXXXXXXXXXXXXX
            - name: MINIO_BROWSER
              value: &quot;on&quot;
            - name: MINIO_PROMETHEUS_AUTH_TYPE
              value: public
          image: minio/minio
          imagePullPolicy: Always
          name: minio1-docker
          ports:
            - containerPort: 9001
              name: console
            - containerPort: 9000
              name: bucket
          securityContext:
            privileged: false
            readOnlyRootFilesystem: false
            runAsNonRoot: false
          volumeMounts:
            - mountPath: /data
              name: data
      dnsConfig:
        nameservers: []
        options: []
        searches: []
      dnsPolicy: ClusterFirst
      hostAliases: []
      initContainers: []
      restartPolicy: Always
      securityContext:
        fsGroupChangePolicy: Always
        runAsNonRoot: false
        sysctls: []
      setHostnameAsFQDN: false
      volumes:
        - emptyDir: {}
          name: data
---
apiVersion: v1
kind: Service
metadata:
  labels:
    use-default-egress-policy: &quot;true&quot;
  name: minio1
  namespace: ns-monitoring
spec:
  externalIPs: []
  ports:
    - port: 443
      targetPort: 9001
  selector:
    cdk8s.deployment: stack-minio1-minio1-deployment-c8e6c44f
  type: ClusterIP
</code></pre>

dbrrt
<p>As mentioned in the <a href="https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#ports" rel="nofollow noreferrer">document</a>:</p>
<blockquote>
<p>List of ports to expose from the container. Not specifying a port here
DOES NOT prevent that port from being exposed. Any port which is
listening on the default &quot;0.0.0.0&quot; address inside a container will be
accessible from the network</p>
</blockquote>
<p>.</p>
<p>As @user2311578 suggested Exposing it on the container level does not make it available automatically on the service. You must specify it there when you want to access it through the service (and its virtual IP).</p>
<p>Also check the <a href="https://github.com/kubernetes/kubernetes/issues/108255" rel="nofollow noreferrer">GitHub</a> link for more information.</p>
