在 Amazon Elastic Kubernetes Service 上安装 Red Hat Developer Hub
使用 Operator 或 Helm chart 在 Amazon Elastic Kubernetes Service (EKS)上运行 Red Hat Developer Hub
摘要
前言 复制链接链接已复制到粘贴板!
您可以使用以下方法之一在 Amazon Elastic Kubernetes Service (EKS)上安装 Red Hat Developer Hub:
- Red Hat Developer Hub Operator
- Red Hat Developer Hub Helm chart
第 1 章 使用 Operator 在 EKS 上安装 Developer Hub 复制链接链接已复制到粘贴板!
Red Hat Developer Hub Operator 安装需要 Operator Lifecycle Manager (OLM)框架。
其他资源
- 有关 OLM 的详情,请参考 Operator Lifecycle Manager (OLM) 文档。
1.1. 使用 OLM 框架安装 Developer Hub Operator 复制链接链接已复制到粘贴板!
您可以使用 Operator Lifecycle Manager (OLM)框架在 EKS 上安装 Developer Hub Operator。之后,您可以继续在 EKS 中部署 Developer Hub 实例。
先决条件
-
在当前
kubeconfig中将上下文设置为 EKS 集群。如需更多信息,请参阅为 Amazon EKS 集群创建或更新 kubeconfig 文件。 -
已安装
kubectl。如需更多信息,请参阅 安装或更新 kubectl。 -
您已订阅了
registry.redhat.io。如需更多信息,请参阅 Red Hat Container Registry 身份验证。 - 已安装 Operator Lifecycle Manager (OLM)。有关安装和故障排除的更多信息,请参阅 OLM QuickStart 或 How do I get Operator Lifecycle Manager?
流程
在终端中运行以下命令,以创建安装 Operator 的
rhdh-operator命名空间:kubectl create namespace rhdh-operator使用以下命令创建 pull secret:
kubectl -n rhdh-operator create secret docker-registry rhdh-pull-secret \ --docker-server=registry.redhat.io \ --docker-username=<user_name> \1 --docker-password=<password> \2 --docker-email=<email>3 创建的 pull secret 用于从红帽生态系统中拉取 Developer Hub 镜像。
创建一个包含红帽生态系统中的 Operator 的
CatalogSource资源:cat <<EOF | kubectl -n rhdh-operator apply -f - apiVersion: operators.coreos.com/v1alpha1 kind: CatalogSource metadata: name: redhat-catalog spec: sourceType: grpc image: registry.redhat.io/redhat/redhat-operator-index:v4.18 secrets: - "rhdh-pull-secret" displayName: Red Hat Operators EOF按如下所示创建
OperatorGroup资源:cat <<EOF | kubectl apply -n rhdh-operator -f - apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: rhdh-operator-group EOF使用以下代码创建
Subscription资源:cat <<EOF | kubectl apply -n rhdh-operator -f - apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: rhdh namespace: rhdh-operator spec: channel: fast installPlanApproval: Automatic name: rhdh source: redhat-catalog sourceNamespace: rhdh-operator startingCSV: rhdh-operator.v1.6.3 EOF运行以下命令,以验证创建的 Operator 是否正在运行:
kubectl -n rhdh-operator get pods -w如果 Operator pod 显示
ImagePullBackOff状态,则可能需要权限直接在 Operator 部署清单中拉取镜像。提示您可以在
deployment.spec.template.spec.imagePullSecrets列表中包括所需的 secret 名称,并使用kubectl get deployment -n rhdh-operator命令验证部署名称:kubectl -n rhdh-operator patch deployment \ rhdh.fast --patch '{"spec":{"template":{"spec":{"imagePullSecrets":[{"name":"rhdh-pull-secret"}]}}}}' \ --type=merge
1.2. 使用 Operator 在 EKS 上部署 Developer Hub 实例 复制链接链接已复制到粘贴板!
先决条件
- 集群管理员已安装了 Red Hat Developer Hub Operator。
- 已安装带有 AWS Application Load Balancer (ALB)附加组件的 EKS 集群。如需更多信息,请参阅 Amazon Elastic Kubernetes Service 上的应用程序负载均衡 和 安装 AWS Load Balancer Controller 附加组件。
- 您已为 Developer Hub 实例配置了域名。域名可以是 Route 53 上的托管区条目,也可以在 AWS 之外管理。如需更多信息,请参阅 将 Amazon Route 53 配置为您的 DNS 服务 文档。
- 您在 AWS 证书管理器(ACM)中有一个条目,用于您首选的域名。确保保留证书 ARN 的记录。
-
您已订阅了
registry.redhat.io。如需更多信息,请参阅 Red Hat Container Registry 身份验证。 -
在当前
kubeconfig中将上下文设置为 EKS 集群。如需更多信息,请参阅为 Amazon EKS 集群创建或更新 kubeconfig 文件。 -
已安装
kubectl。如需更多信息,请参阅 安装或更新 kubectl。
流程
使用以下模板创建一个包含
app-config.yamlDeveloper Hub 配置文件的my-rhdh-app-config配置映射:apiVersion: v1 kind: ConfigMap metadata: name: my-rhdh-app-config data: "app-config.yaml": | app: title: Red Hat Developer Hub baseUrl: https://<rhdh_dns_name> backend: auth: externalAccess: - type: legacy options: subject: legacy-default-config secret: "${BACKEND_SECRET}" baseUrl: https://<rhdh_dns_name> cors: origin: https://<rhdh_dns_name>创建一个 Red Hat Developer Hub secret,并添加名为
BACKEND_SECRET的键,其带有Base64 编码的字符串作为值:apiVersion: v1 kind: Secret metadata: name: <my_product_secrets>1 stringData: # TODO: See https://backstage.io/docs/auth/service-to-service-auth/#setup BACKEND_SECRET: "xxx"- 1
<my_product_secrets> 是您首选的 Developer Hub secret 名称,其中 <my_product_secrets> 指定 Developer Hub 中 secret 配置的唯一标识符。
重要确保为每个 Developer Hub 实例使用唯一的
BACKEND_SECRET值。您可以使用以下命令生成密钥:
node-p'require("crypto").randomBytes(24).toString("base64")'要启用从 Red Hat Ecosystem Catalog 拉取 PostgreSQL 镜像,请在部署 Developer Hub 实例的命名空间中的 default 服务帐户中添加镜像 pull secret:
kubectl patch serviceaccount default \ -p '{"imagePullSecrets": [{"name": "rhdh-pull-secret"}]}' \ -n <your_namespace>使用以下模板创建
Backstage自定义资源:apiVersion: rhdh.redhat.com/v1alpha3 kind: Backstage metadata: # TODO: this the name of your Developer Hub instance name: my-rhdh spec: application: imagePullSecrets: - "rhdh-pull-secret" route: enabled: false appConfig: configMaps: - name: my-rhdh-app-config extraEnvs: secrets: - name: <my_product_secrets>1 - 1
<my_product_secrets> 是您首选的 Developer Hub secret 名称,其中 <my_product_secrets> 指定 Developer Hub 中 secret 配置的标识符。
使用以下模板创建 Ingress 资源,确保根据需要自定义名称:
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: # TODO: this the name of your Developer Hub Ingress name: my-rhdh annotations: alb.ingress.kubernetes.io/scheme: internet-facing alb.ingress.kubernetes.io/target-type: ip # TODO: Using an ALB HTTPS Listener requires a certificate for your own domain. Fill in the ARN of your certificate, e.g.: alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:us-xxx:xxxx:certificate/xxxxxx alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]' alb.ingress.kubernetes.io/ssl-redirect: '443' # TODO: Set your application domain name. external-dns.alpha.kubernetes.io/hostname: <rhdh_dns_name> spec: ingressClassName: alb rules: # TODO: Set your application domain name. - host: <rhdh_dns_name> http: paths: - path: / pathType: Prefix backend: service: # TODO: my-rhdh is the name of your `Backstage` custom resource. # Adjust if you changed it! name: backstage-my-rhdh port: name: http-backend在前面的模板中,将 ' <rhdh_dns_name>' 替换为您的 Developer Hub 域名,并将
alb.ingress.kubernetes.io/certificate-arn的值替换为您的证书 ARN。
验证
等待 DNS 名称响应,这表示您的 Developer Hub 实例已准备就绪。
第 2 章 使用 Helm Chart 在 EKS 上安装 Developer Hub 复制链接链接已复制到粘贴板!
当您在 Elastic Kubernetes Service (EKS)中安装 Developer Hub Helm Chart 时,它会编配 Developer Hub 实例的部署,它在 AWS 生态系统中提供了强大的开发人员平台。
先决条件
- 已安装带有 AWS Application Load Balancer (ALB)附加组件的 EKS 集群。如需更多信息,请参阅 Amazon Developer Hub 上的应用程序负载均衡 和 安装 AWS Load Balancer Controller 附加组件。
- 您已为 Developer Hub 实例配置了域名。域名可以是 Route 53 上的托管区条目,也可以在 AWS 之外管理。如需更多信息,请参阅 将 Amazon Route 53 配置为您的 DNS 服务 文档。
- 您在 AWS 证书管理器(ACM)中有一个条目,用于您首选的域名。确保保留证书 ARN 的记录。
-
您已订阅了
registry.redhat.io。如需更多信息,请参阅 Red Hat Container Registry 身份验证。 -
在当前
kubeconfig中将上下文设置为 EKS 集群。如需更多信息,请参阅为 Amazon EKS 集群创建或更新 kubeconfig 文件。 -
已安装
kubectl。如需更多信息,请参阅 安装或更新 kubectl。 - 已安装 Helm 3 或最新的。如需更多信息,请参阅在 Amazon EKS 中使用 Helm。
流程
进入终端并运行以下命令,将包含 Developer Hub chart 的 Helm Chart 仓库添加到本地 Helm registry 中:
helm repo add openshift-helm-charts https://charts.openshift.io/使用以下命令创建 pull secret:
kubectl create secret docker-registry rhdh-pull-secret \ --docker-server=registry.redhat.io \ --docker-username=<user_name> \1 --docker-password=<password> \2 --docker-email=<email>3 创建的 pull secret 用于从红帽生态系统中拉取 Developer Hub 镜像。
使用以下模板创建一个名为
values.yaml的文件:global: # TODO: Set your application domain name. host: <your Developer Hub domain name> route: enabled: false upstream: service: # NodePort is required for the ALB to route to the Service type: NodePort ingress: enabled: true annotations: kubernetes.io/ingress.class: alb alb.ingress.kubernetes.io/scheme: internet-facing # TODO: Using an ALB HTTPS Listener requires a certificate for your own domain. Fill in the ARN of your certificate, e.g.: alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:xxx:xxxx:certificate/xxxxxx alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]' alb.ingress.kubernetes.io/ssl-redirect: '443' # TODO: Set your application domain name. external-dns.alpha.kubernetes.io/hostname: <your rhdh domain name> backstage: image: pullSecrets: - rhdh-pull-secret podSecurityContext: # you can assign any random value as fsGroup fsGroup: 2000 postgresql: image: pullSecrets: - rhdh-pull-secret primary: podSecurityContext: enabled: true # you can assign any random value as fsGroup fsGroup: 3000 volumePermissions: enabled: true在终端中运行以下命令,以使用最新版本的 Helm Chart 并使用上一步中创建的 values.yaml 文件部署 Developer Hub:
helm install rhdh \ openshift-helm-charts/redhat-developer-hub \ [--version 1.6.3] \ --values /path/to/values.yaml
验证
等待 DNS 名称响应,这表示您的 Developer Hub 实例已准备就绪。