This is a quick guide on how to deploy Dex, an open source, self-hosted identity provider (IdP) on the same underlying Kubernetes cluster that is running the Octelium Cluster and use it as an OpenID Connect IdentityProvider (read more about IdentityProviders here) to be able to login to the Cluster.
In this guide we use Helm to install Dex. First, we need to create a values.yaml YAML file for the Dex Helm chart (see the chart here) as follows:
1image:2repository: ghcr.io/dexidp/dex34config:5issuer: https://idp.<DOMAIN>/dex6storage:7type: kubernetes8config:9inCluster: true10web:11http: 0.0.0.0:55561213staticClients:14- id: octelium15redirectURIs:16- "https://<DOMAIN>/callback"17name: "My Demo App"18secret: <CLIENT_SECRET>1920staticPasswords:21- email: <YOUR_EMAIL>22hash: <PASSWORD_BCRYPT_HASH>23username: "admin"24userID: <UUID_V4>2526enablePasswordDB: true
You can, for example, use Python to generate a bcrypt hash of a password for the hash field as follows:
python -c 'import bcrypt; print(bcrypt.hashpw("<YOUR_PASSWORD>".encode(), bcrypt.gensalt()).decode())'
You can also use Python to generate a UUIDv4 for the userID field as follows:
python -c 'import uuid; print(uuid.uuid4())'
Now deploy Dex on the Kubernetes cluster using the values.yaml file shown above as follows:
helm repo add dex https://charts.dexidp.iohelm repo updatehelm install octelium-dex --namespace octelium -f </PATH/TO/VALUES.YAML>
Now create an Octelium Service with the Dex web server as an upstream as follows:
1kind: Service2metadata:3name: idp4spec:5mode: HTTP6config:7upstream:8url: http://octelium-dex.octelium.svc:55569http:10header:11host:12preserve: true13isPublic: true14isAnonymous: true
Now you can apply the creation of the Service via the octeliumctl apply command (read more here) as follows:
octeliumctl apply /PATH/TO/SERVICE.YAML
Notice that we created the Service as isAnonymous since we need to access it anonymously in order to login to the Cluster. You can read more about anonymous Services here.
Now create an a Secret for the application's client secret as follows:
octeliumctl create secret dex-client
Now create an OpenID Connect IdentityProvider using the application's client id, the client secret's Secret and the issuer URL as follows:
1kind: IdentityProvider2metadata:3name: dex4spec:5displayName: Main Login6oidc:7clientID: octelium8clientSecret:9fromSecret: dex-client10issuerURL: https://idp.<DOMAIN>/dex
Now you can apply the creation of the IdentityProvider via the octeliumctl apply command as follows:
octeliumctl apply /PATH/TO/IDENTITY_PROVIDER.YAML
Now you can visit the URL https://<DOMAIN> to be able to login to the Cluster with Dex via your <YOUR_EMAIL> and <YOUR_PASSWORD> set above in the values.yaml Helm file.