nexus的kubernetes中未暴露已部署的端口

时间:2018-12-11 15:08:08

标签: kubernetes nexus kubernetes-ingress persistent-volumes persistent-volume-claims


  我正在通过kubernetes创建一个nexus回购。通过浏览,我遇到了这个站点(https://blog.sonatype.com/kubernetes-recipe-sonatype-nexus-3-as-a-private-docker-registry),我能够创建服务和部署,以及创建的pod和所有内容。但是我无法打开它。

这是我的nexus.yaml文件

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

当我给
     kubectl描述服务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>

我尝试提供端口并打开,但遇到错误,可以到达。

有人可以帮我吗??? 预先感谢。

1 个答案:

答案 0 :(得分:0)

在查看了上面的yml文件后,您已将名称空间写为“ nexus”,请尝试通过将名称空间更改为“ default”来运行。