0


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
  • 39
  • 8
  • "I tried by giving the port and opening but i am getting a error it can reached." presumably you mean "it can't be reached"? _edit:_ I didn't see the `Ingress` the first time, but my question stands: what does "giving the port and it can't be reached" mean, exactly? – mdaniel Dec 12 '18 at 04:12
  • What i meant was when i try to open the port with minikube IP Address along with the port number. It is saying that unable to connect or the server took long time to respond. The minikube IP address means that when i give minikube ip i will get IP address for minikube. – Kishan Jr Dec 12 '18 at 04:57
  • Sorry not as unable to connect it shows as the site can't be reached. – Kishan Jr Dec 12 '18 at 05:25
  • you continue to say "the port number" as if we know what that means; please try to help us to help you -- being vague does not help. If you are using minikube, you will want to find the `NodePort` that exposes your ingress-controller, since **that** is the port you should send your requests to. Also, unless you have a DNS name pointing at your **minikube** IP, the virtual-hosting the ingress controller uses will not work correctly. You can try it out using curl, or by editing your `/etc/hosts` I guess, but it won't "just work" – mdaniel Dec 12 '18 at 05:59
  • Sorry what i meant by port number was the endpoint 172.17.0.11:8081. – Kishan Jr Dec 12 '18 at 06:01
  • I didn't get you "unless you have a DNS name pointing at your minikube IP, the virtual-hosting the ingress controller uses will not work correctly" can you explain it with an example ??? – Kishan Jr Dec 12 '18 at 06:04
  • I also checked the /etc/host in my ssh and found this. Kubernetes-managed hosts file. 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet fe00::0 ip6-mcastprefix fe00::1 ip6-allnodes fe00::2 ip6-allrouters 172.17.0.11 nexus-759dcdf89-grkhx – Kishan Jr Dec 12 '18 at 06:07
  • I also found when i give curl 172.17.0.11:8081 in the shell i am able to see the html content with Nexus Repository Manager. But when i give the same in the browser i am able to see as the site can't be reached. – Kishan Jr Dec 12 '18 at 06:16

1 Answers1

0

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