跳到主要内容

在 ROSA 上安装 APISIX

Red Hat OpenShift Service on AWS (ROSA) 是一项完全托管的服务,提供了一种在 AWS 上部署和管理 OpenShift 集群的简化方法。

前置条件

  • 拥有一个 AWS 帐户
  • 拥有一个 Red Hat 帐户
  • 按照 ROSA 入门 学习路径进行操作:
    • 在 OpenShift 中设置 AWS
    • 部署集群
    • 向用户授予集群管理员权限
  • 安装 ROSA CLI
  • 安装 OpenShift CLI 并使用具有集群管理员权限的用户凭证 登录
  • 安装 Helm CLI

创建 OpenShift 项目和服务帐户

使用具有集群管理员权限的用户帐户登录 OpenShift CLI:

oc login <cluster-url> --username <username> --password <password>

为 APISIX 创建一个 OpenShift 项目:

oc new-project apisix

将默认项目切换到 apisix

oc project apisix

为 APISIX 部署创建服务帐户 apisix-sa

oc create sa apisix-sa

安全上下文约束 (SCC) nonroot-v2 添加到服务帐户:

oc adm policy add-scc-to-user nonroot-v2 -z apisix-sa

使用 Helm 安装

添加 APISIX Helm 仓库并更新:

helm repo add apisix https://apache.github.io/apisix-helm-chart
helm repo update

安装 APISIX Helm chart:

helm install apisix apisix/apisix \
--set gateway.type=NodePort \
// Annotate 1
--set etcd.podSecurityContext.enabled=false \
--set etcd.containerSecurityContext.enabled=false \
// Annotate 2
--set serviceAccount.name=apisix-sa

❶ 禁用 etcd 的 podSecurityContextcontainerSecurityContext 以避免遇到 与 SCC 相关的问题

❷ 使用服务帐户 apisix-sa 进行部署,以授予 APISIX 所需的权限。

如果成功,你应该看到类似以下的响应:

NAME: apisix
LAST DEPLOYED: Wed May 24 07:56:25 2023
NAMESPACE: apisix
STATUS: deployed

验证安装

检查 pod 状态以确保所有 pod 都已启动并正在运行:

oc get pod

响应应类似于以下内容,所有 pod 均为 Running

NAME                      READY   STATUS    RESTARTS   AGE
apisix-5899557df4-5wgcn 1/1 Running 0 6m33s
apisix-etcd-0 1/1 Running 0 6m33s
apisix-etcd-1 1/1 Running 0 6m33s
apisix-etcd-2 1/1 Running 0 6m33s

向 APISIX 发送请求以验证 APISIX 正在运行:

oc exec -itq apisix-5899557df4-5wgcn -- curl -I http://127.0.0.1:9080 | grep Server

你应该在响应中看到 APISIX 版本:

Server: APISIX/3.13.0

你现在已成功在 ROSA 上安装 APISIX。