Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
| devops:deploy_nexus_on_kubernetes [2020/03/20 13:59] – [Nexus Service and Ingress] admin | devops:deploy_nexus_on_kubernetes [2020/03/20 13:59] (current) – [Nexus Service and Ingress] admin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Задача ====== | ||
| + | Нужно развернуть **Nexus Repository 3** внутри кластера **Kubernetes**. \\ | ||
| + | В кластере настроен **LoadBalancer** и **CertManager**. \\ | ||
| + | Образ Docker есть на **hub.docker.com**. \\ | ||
| + | ====== Nexus Namespace ====== | ||
| + | kubectl create ns nexus | ||
| + | |||
| + | ====== Nexus StorageClass PersistentVolumeClaim PersistentVolume ====== | ||
| + | Для работы **Nexus** нужна директория. где он будет хранить артефакты. Для этого создаим **StorageClass**, | ||
| + | < | ||
| + | kind: StorageClass | ||
| + | metadata: | ||
| + | name: nexus-storage-class | ||
| + | namespace: nexus | ||
| + | provisioner: | ||
| + | reclaimPolicy: | ||
| + | volumeBindingMode: | ||
| + | --- | ||
| + | apiVersion: v1 | ||
| + | kind: PersistentVolumeClaim | ||
| + | metadata: | ||
| + | name: nexus-data-pv-claim | ||
| + | namespace: nexus | ||
| + | spec: | ||
| + | storageClassName: | ||
| + | accessModes: | ||
| + | - ReadWriteOnce | ||
| + | resources: | ||
| + | requests: | ||
| + | storage: 20Gi | ||
| + | selector: | ||
| + | matchLabels: | ||
| + | app: nexus-server | ||
| + | --- | ||
| + | apiVersion: v1 | ||
| + | kind: PersistentVolume | ||
| + | metadata: | ||
| + | name: nexus-data-pv | ||
| + | | ||
| + | | ||
| + | app: nexus-server | ||
| + | spec: | ||
| + | capacity: | ||
| + | storage: 20Gi | ||
| + | accessModes: | ||
| + | - ReadWriteOnce | ||
| + | storageClassName: | ||
| + | hostPath: | ||
| + | path: "/ | ||
| + | type: Directory | ||
| + | persistentVolumeReclaimPolicy: | ||
| + | |||
| + | ====== Nexus deployment ====== | ||
| + | < | ||
| + | kind: Deployment | ||
| + | metadata: | ||
| + | name: nexus | ||
| + | namespace: nexus | ||
| + | spec: | ||
| + | replicas: 1 | ||
| + | selector: | ||
| + | matchLabels: | ||
| + | app: nexus-server | ||
| + | template: | ||
| + | metadata: | ||
| + | labels: | ||
| + | app: nexus-server | ||
| + | spec: | ||
| + | containers: | ||
| + | - name: nexus | ||
| + | image: sonatype/ | ||
| + | resources: | ||
| + | limits: | ||
| + | memory: " | ||
| + | cpu: " | ||
| + | requests: | ||
| + | memory: " | ||
| + | cpu: " | ||
| + | ports: | ||
| + | - containerPort: | ||
| + | volumeMounts: | ||
| + | - name: nexus-data | ||
| + | mountPath: /nexus-data | ||
| + | volumes: | ||
| + | - name: nexus-data | ||
| + | persistentVolumeClaim: | ||
| + | claimName: nexus-data-pv-claim</ | ||
| + | |||
| + | ====== Nexus Service and Ingress ====== | ||
| + | < | ||
| + | kind: Service | ||
| + | metadata: | ||
| + | name: nexus-svc | ||
| + | namespace: nexus | ||
| + | annotations: | ||
| + | prometheus.io/ | ||
| + | prometheus.io/ | ||
| + | prometheus.io/ | ||
| + | spec: | ||
| + | selector: | ||
| + | app: nexus-server | ||
| + | type: ClusterIP | ||
| + | ports: | ||
| + | - name: http | ||
| + | port: 80 | ||
| + | protocol: TCP | ||
| + | targetPort: 8081 | ||
| + | - name: docker-registry | ||
| + | port: 5000 | ||
| + | protocol: TCP | ||
| + | targetPort: 5000 | ||
| + | --- | ||
| + | apiVersion: extensions/ | ||
| + | kind: Ingress | ||
| + | metadata: | ||
| + | annotations: | ||
| + | kubernetes.io/ | ||
| + | cert-manager.io/ | ||
| + | nginx.ingress.kubernetes.io/ | ||
| + | nginx.ingress.kubernetes.io/ | ||
| + | nginx.ingress.kubernetes.io/ | ||
| + | nginx.ingress.kubernetes.io/ | ||
| + | name: nexus-ingress | ||
| + | namespace: nexus | ||
| + | spec: | ||
| + | rules: | ||
| + | - host: nexus.domain.com | ||
| + | http: | ||
| + | paths: | ||
| + | - backend: | ||
| + | serviceName: | ||
| + | servicePort: | ||
| + | path: / | ||
| + | tls: | ||
| + | - hosts: | ||
| + | - nexus.domain.com | ||
| + | secretName: | ||
| + | --- | ||
| + | apiVersion: extensions/ | ||
| + | kind: Ingress | ||
| + | metadata: | ||
| + | annotations: | ||
| + | kubernetes.io/ | ||
| + | cert-manager.io/ | ||
| + | nginx.ingress.kubernetes.io/ | ||
| + | nginx.ingress.kubernetes.io/ | ||
| + | nginx.ingress.kubernetes.io/ | ||
| + | nginx.ingress.kubernetes.io/ | ||
| + | name: nexus-docker-ingress | ||
| + | namespace: nexus | ||
| + | spec: | ||
| + | rules: | ||
| + | - host: registry.autosys.tk | ||
| + | http: | ||
| + | paths: | ||
| + | - backend: | ||
| + | serviceName: | ||
| + | servicePort: | ||
| + | path: / | ||
| + | tls: | ||
| + | - hosts: | ||
| + | - registry.autosys.tk | ||
| + | secretName: | ||
| + | </ | ||
| + | ====== Дефолтный пароль admin ====== | ||
| + | Администативная учетка - **admin**. \\ | ||
| + | Пароль по-умолчанию от учетки **admin** генерируется во время deplyment' | ||