Deployed port is not getting exposed in kubernetes in nexus

12/11/2018


I am working on creating a nexus repo through kubernetes. By browesing i came across this site (https://blog.sonatype.com/kubernetes-recipe-sonatype-nexus-3-as-a-private-docker-registry) I was able to create a service and deployment and pod and everthing created without am issue. But i was not able to open it.

This is my nexus.yaml file

apiVersion: v1
kind: Namespace
metadata:
  name: nexus 
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nexusvolume-local
  namespace: nexus
  labels:
    app: nexus
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nexus
  namespace: nexus
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: nexus
    spec:
      containers:
      - image: sonatype/nexus3
        imagePullPolicy: Always
        name: nexus
        ports:
        - containerPort: 8081
        - containerPort: 5000
        volumeMounts:
          - mountPath: /nexus-data
            name: nexus-data-volume
      volumes:
        - name: nexus-data-volume
          persistentVolumeClaim:
            claimName: nexusvolume-local
---
apiVersion: v1
kind: Service
metadata:
  name: nexus-service
  namespace: nexus
spec:
  ports:
  - port: 80
    targetPort: 8081
    protocol: TCP
    name: http
  - port: 5000
    targetPort: 5000
    protocol: TCP
    name: docker 
  selector:
    app: nexus
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nexus-ingress
  namespace: nexus
  annotations:
    ingress.kubernetes.io/proxy-body-size: 100m
    kubernetes.io/tls-acme: "true"
    kubernetes.io/ingress.class: "nginx"
spec:
  tls:
  - hosts:
    # CHANGE ME
    - docker.testnexusurl.com
    - nexus.testnexusurl.com 
    secretName: nexus-tls
  rules:
  # CHANGE ME
  - host: nexus.testnexusurl.com 
    http:
      paths:
      - path: /
        backend:
          serviceName: nexus-service
          servicePort: 80
  # CHANGE ME
  - host: docker.testnexusurl.com 
    http:
      paths:
      - path: /
        backend:
          serviceName: nexus-service
          servicePort: 5000

When i give
kubectl describe service nexus-service -n nexus

Name:              nexus-service
Namespace:         nexus
Labels:            <none>
Annotations:       <none>
Selector:          app=nexus
Type:              ClusterIP
IP:                10.111.212.3
Port:              http  80/TCP
TargetPort:        8081/TCP
Endpoints:         172.17.0.11:8081
Port:              docker  5000/TCP
TargetPort:        5000/TCP
Endpoints:         172.17.0.11:5000
Session Affinity:  None
Events:            <none>

I tried by giving the port and opening but i am getting a error it can reached.

Can someone help me on this??? Thanks in advance.

-- Kishan Jr
kubernetes
kubernetes-ingress
nexus
persistent-volume-claims
persistent-volumes

1 Answer

12/13/2018

After looking at the above yml file, there you have written namespace as "nexus", try running by changing namespace to "default".

-- Rahul Tibrewal
Source: StackOverflow