ingress_harbor安装和使用
原创小于 1 分钟
ingress_harbor安装和使用
本实践将在 Ubuntu 22.04.3LTS 系统上进行安装测试
docker版本 24.0.6
kubeadm版本 v1.28 次新版本
操作步骤
harbor 通过ingress 访问
## 创建证书到k8s
kubectl create secret tls tls-secret --cert=/harbor/cert/registry.home.com.crt --key=/harbor/cert/registry.home.com.key
kubectl get secret tls tls-secret -o yaml > tls-secret.yaml
yaml 文件
apiVersion: v1
kind: Namespace
metadata:
labels:
app.kubernetes.io/instance: Home
app.kubernetes.io/name: Home
name: Home
---
apiVersion: v1
items:
- apiVersion: v1
data:
tls.crt: LS0tLS1xxxxxxx
tls.key: LS0tLS1xxxxxxx
kind: Secret
metadata:
name: tls-secret
namespace: Home
type: kubernetes.io/tls
kind: List
metadata:
resourceVersion: ""
---
apiVersion: v1
kind: Service
metadata:
name: harbor
namespace: Home
spec:
externalName: 172.xxx.xxx.xxx
ports:
- name: https
port: 443
protocol: TCP
targetPort: 443
sessionAffinity: None
type: ExternalName
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: harbor
namespace: Home
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: "0"
nginx.ingress.kubernetes.io/backend-protocol: HTTPS
spec:
tls:
- hosts:
- registry.home.com
secretName: tls-secret
rules:
- host: registry.home.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: harbor
port:
number: 443
ingressClassName: nginx
启动
kubecll apply -f harbor-ingress.yaml
kubectl get ingress -n Home
访问
https://registry.home.com