cluster-authentication-operator
认证 operator 是一个
OpenShift ClusterOperator。
它在集群中安装并维护 Authentication Custom Resource,并可通过以下方式查看:
oc get clusteroperator authentication -o yaml
Custom Resource Definition
authentications.operator.openshift.io
可通过以下方式在集群中查看:
$ oc get crd authentications.operator.openshift.io -o yaml
此 Operator 管理的内容
身份验证 Operator 管理以下操作数:
- oauth-openshift —
openshift-authentication命名空间中的 OAuth 服务器部署。处理用户身份验证流程、登录模板和令牌生成。 - oauth-apiserver —
openshift-oauth-apiserver命名空间中的 OAuth API 服务器部署。提供 OAuth API 资源(OAuthAccessTokens、OAuthAuthorizeTokens、OAuthClients)。
对于每个操作数,Operator 管理相关的 Deployments、Services、RBAC、NetworkPolicies、PodDisruptionBudgets 以及监控资源(PrometheusRules、ServiceMonitor)。
如需深入了解 Operator 的架构,请参阅 ARCHITECTURE.md。
开发
许多 OpenShift ClusterOperator 共享通用的构建、测试、部署和更新方法。 有关如何构建、部署、测试、更新和开发 OpenShift ClusterOperator 的更多信息,请参阅 OpenShift ClusterOperator 和操作数开发者文档。
若要使用您的测试 cluster-authentication-operator 镜像部署 OpenShift,请参阅 在集群中测试 ClusterOperator/操作数镜像。
有关贡献指南,包括预提交检查、依赖项管理和测试要求,请参阅 CONTRIBUTING.md。
添加基本 IdP 以测试您的内容
用于演示和测试的最常见身份提供商是 HTPasswd IdP。
要进行设置,请执行以下步骤:
- Create a new htpasswd file
$ htpasswd -bBc /tmp/htpasswd testuser testpasswd
- (optional) Add more users
$ htpasswd -bB /tmp/htpasswd testuser2 differentpassword
- Create a secret from that htpasswd in the
openshift-confignamespace
oc create secret generic myhtpasswdidp-secret -n openshift-config --from-file=/tmp/htpasswd
- Configure the OAuth server to use the HTPasswd IdP from the secret by editing the spec of the cluster-wide OAuth/cluster object so that it looks like the one in this example:
apiVersion: config.openshift.io/v1
kind: OAuth
metadata:
name: cluster
spec:
identityProviders:
- name: htpassidp
type: HTPasswd
htpasswd:
fileData:
name: myhtpasswdidp-secret
- The operator will now restart the OAuth server deployment and mount the new config
- When the operator is available again (
oc get clusteroperator authentication), you should be able to log in:
oc login -u testuser -p testpasswd
测试
本仓库与 OpenShift Tests Extension (OTE) 框架兼容。
构建测试二进制文件
make build
运行测试套件和测试
# Run a specific test suite
./cluster-authentication-operator-tests-ext run-suite openshift/cluster-authentication-operator/operator/parallel
# Run with parallel execution (4 workers)
./cluster-authentication-operator-tests-ext run-suite openshift/cluster-authentication-operator/operator/parallel -c 4
# Run with JUnit output
./cluster-authentication-operator-tests-ext run-suite openshift/cluster-authentication-operator/operator/parallel --junit-path "${ARTIFACT_DIR}/junit.xml"
# Run a specific test
./cluster-authentication-operator-tests-ext run-test "test-name"
列出可用的测试和测试套件
# List all test suites
./cluster-authentication-operator-tests-ext list suites
# List tests in a suite
./cluster-authentication-operator-tests-ext list tests --suite=openshift/cluster-authentication-operator/operator/parallel
有关 OTE 框架的更多信息,请参阅 openshift-tests-extension 文档。