AWS EKS OIDC Integration
This page shows how to provision the Keycloak realm, client, group, and user resources needed for EKS OIDC by installing the edp-keycloak-operator via Helm and applying its Custom Resources β Keycloak, KeycloakRealm, KeycloakRealmGroup, KeycloakClientScope, KeycloakClient, and KeycloakRealmUser. It covers only the Keycloak-side resource provisioning; for the end-to-end setup of EKS cluster access β associating Keycloak as the EKS OIDC provider and mapping groups to Kubernetes RBAC roles β see Keycloak as OIDC Provider for AWS EKS.
Prerequisitesβ
- EKS Configuration is performed
- A recent Helm 3.x release is installed
- Keycloak is installed
Install Keycloak Operatorβ
Alternately, the edp-keycloak-operator can be installed using a GitOps approach via the edp-cluster-add-ons repository. For detailed installation instructions, please refer to the Install via Add-ons guide.
To install the Keycloak operator, follow the steps below:
-
Add the
epamedpHelm chart to a local client:helm repo add epamedp https://epam.github.io/edp-helm-charts/stablehelm repo update -
Install the Keycloak operator:
helm install keycloak-operator epamedp/keycloak-operator --namespace security --set name=keycloak-operator
Connect Keycloak Operator to Keycloakβ
It is also possible to install Keycloak resources using the edp-cluster-add-ons repository. For details, please refer to the Install via Add-Ons page.
The next stage after installing Keycloak is to integrate it with the Keycloak operator. It can be implemented with the following steps:
-
Create the keycloak secret that contains username and password defined on the configuration step:
kubectl -n security create secret generic keycloak \--from-literal=username=<username> \--from-literal=password=<password> -
Create the Keycloak Custom Resource with the Keycloak instance URL and the secret created in the previous step:
apiVersion: v1.edp.epam.com/v1kind: Keycloakmetadata:name: mainnamespace: securityspec:secret: keycloak # Secret nameurl: https://keycloak.example.com # Keycloak URL -
Create the KeycloakRealm Custom Resource:
apiVersion: v1.edp.epam.com/v1kind: KeycloakRealmmetadata:name: control-planenamespace: securityspec:realmName: control-planekeycloakOwner: main -
Create the
KeycloakRealmGroupCustom Resource for both administrators and developers:-
administrators:
apiVersion: v1.edp.epam.com/v1kind: KeycloakRealmGroupmetadata:name: administratorsnamespace: securityspec:realm: control-planename: eks-oidc-administrator -
developers:
apiVersion: v1.edp.epam.com/v1kind: KeycloakRealmGroupmetadata:name: developersnamespace: securityspec:realm: control-planename: eks-oidc-developers
-
-
Create the
KeycloakClientScopeCustom Resource:apiVersion: v1.edp.epam.com/v1kind: KeycloakClientScopemetadata:name: groups-keycloak-eksnamespace: securityspec:name: groupsrealm: control-planedescription: "Group Membership"protocol: openid-connectprotocolMappers:- name: groupsprotocol: openid-connectprotocolMapper: "oidc-group-membership-mapper"config:"access.token.claim": "true""claim.name": "groups""full.path": "false""id.token.claim": "true""userinfo.token.claim": "true" -
Create the
KeycloakClientCustom Resource:apiVersion: v1.edp.epam.com/v1kind: KeycloakClientmetadata:name: eksnamespace: securityspec:advancedProtocolMappers: trueclientId: eksdirectAccess: truepublic: falsedefaultClientScopes:- groupstargetRealm: control-planewebUrl: "http://localhost:8000" -
Create the KeycloakRealmUser Custom Resource for both administrator and developer roles:
-
administrator:
apiVersion: v1.edp.epam.com/v1kind: KeycloakRealmUsermetadata:name: keycloakrealmuser-adminnamespace: securityspec:realm: control-planeusername: "administrator"firstName: "John"lastName: "Snow"email: "administrator@example.com"enabled: trueemailVerified: truepassword: "12345678"keepResource: truerequiredUserActions:- UPDATE_PASSWORDgroups:- eks-oidc-administrator -
developer:
apiVersion: v1.edp.epam.com/v1kind: KeycloakRealmUsermetadata:name: keycloakrealmuser-developernamespace: securityspec:realm: control-planeusername: "developers"firstName: "John"lastName: "Snow"email: "developers@example.com"enabled: trueemailVerified: truepassword: "12345678"keepResource: truerequiredUserActions:- UPDATE_PASSWORDgroups:- eks-oidc-developers
-
-
To connect the created Keycloak resources with permissions, it is necessary to bind the created Keycloak groups to Kubernetes roles, e.g., assigning the Keycloak group
administratorsthe Kubernetes Cluster rolecluster-admin.apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRoleBindingmetadata:name: oidc-cluster-adminssubjects:- kind: GroupapiGroup: rbac.authorization.k8s.ioname: administratorsroleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: cluster-admin -
As a result, Keycloak is integrated with the AWS Elastic Kubernetes Service. This integration allows users to easily log in to the EKS cluster using their kubeconfig files and
kubelogin, while managing permissions through Keycloak. This seamless integration enhances the user experience and streamlines the management of access control within the KubeRocketCI platform.