第 1 章 使用 Operator 在 AKS 上部署 Developer Hub
您可以使用 Red Hat Developer Hub Operator 在 AKS 上部署 Developer Hub。
流程
获取名为
rhdh-operator-<VERSION>.yaml的 Red Hat Developer Hub Operator 清单文件,并通过添加以下片段来修改db-statefulset.yaml和deployment.yaml的默认配置:securityContext: fsGroup: 300以下是清单中的指定位置:
db-statefulset.yaml: | spec.template.spec deployment.yaml: | spec.template.spec将修改后的 Operator 清单应用到 Kubernetes 集群:
kubectl apply -f rhdh-operator-<VERSION>.yaml注意上一命令的执行是集群范围的,需要适当的集群特权。
使用您的红帽凭证创建一个名为
rhdh-pull-secret的ImagePull Secret,以访问受保护的registry.redhat.io中的镜像,如下例所示:kubectl -n <your_namespace> create secret docker-registry rhdh-pull-secret \ --docker-server=registry.redhat.io \ --docker-username=<redhat_user_name> \ --docker-password=<redhat_password> \ --docker-email=<email>创建名为
rhdh-ingress.yaml的 Ingress 清单文件,指定 Developer Hub 服务名称,如下所示:apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: rhdh-ingress namespace: <your_namespace> spec: ingressClassName: webapprouting.kubernetes.azure.com rules: - http: paths: - path: / pathType: Prefix backend: service: name: backstage-<your-CR-name> port: name: http-backend要部署创建的 Ingress,请运行以下命令:
kubectl -n <your_namespace> apply -f rhdh-ingress.yaml使用以下示例,创建一个名为
app-config-rhdh的 ConfigMap,其中包含 Developer Hub 配置:apiVersion: v1 kind: ConfigMap metadata: name: app-config-rhdh data: "app-config-rhdh.yaml": | app: title: Red Hat Developer Hub baseUrl: https://<app_address> backend: auth: externalAccess: - type: legacy options: subject: legacy-default-config secret: "${BACKEND_SECRET}" baseUrl: https://<app_address> cors: origin: https://<app_address>创建名为
secrets-rhdh的 Secret,并使用Base64 编码的字符串值添加名为BACKEND_SECRET的键,如下例所示:apiVersion: v1 kind: Secret metadata: name: secrets-rhdh stringData: BACKEND_SECRET: "xxx"创建名为
rhdh.yaml的自定义资源(CR)清单文件,并包含之前创建的rhdh-pull-secret,如下所示:apiVersion: rhdh.redhat.com/v1alpha1 kind: Backstage metadata: name: <your-rhdh-cr> spec: application: imagePullSecrets: - rhdh-pull-secret appConfig: configMaps: - name: "app-config-rhdh" extraEnvs: secrets: - name: "secrets-rhdh"将 CR 清单应用到您的命名空间:
kubectl -n <your_namespace> apply -f rhdh.yaml-
使用 URL 访问部署的 Developer Hub:
https://<app_address>,其中 <app_address> 是前面获取的 Ingress 地址(例如https://108.141.70.228)。 可选: 要删除 CR,请运行以下命令:
kubectl -n <your_namespace> delete -f rhdh.yaml