Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Kubernetes login portal for both kubectl and the dashboard using GitHub. Use organizations and teams in RBAC policies to control access to your cluster. Supports impersonation and OpenID Connect integration with your API server.

License

NotificationsYou must be signed in to change notification settings

OpenUnison/openunison-k8s-login-github

Repository files navigation

⚠️

Please go tohttps://openunison.github.io/ to integrate your cluster with OpenUnison. This repo is no longer supported and will no longer get updated builds

⚠️

Alt text

Short video of logging into Kubernetes and using kubectl using GitHub

Orchestra Login Portal provides a login portal for Kubernetes that allows you to authenticate with GitHub, use GitHub teams and organizations for RBAC authorizations and provides integration for bothkubectl and the Kubernetes Dashboard (https://github.com/kubernetes/dashboard). The portal runs inside of Kubernetes, leveraging Kubernetes for scalability, secret management and deployment.

Orchestra Login Portal Architecture

When a user accesses Kubernetes using Orchestra, they'll access both the login portal and the dashboard through OpenUnison (instead of directly via an ingress). OpenUnison will inject the user's identity into each request, allowing the dashboard to act on their behalf. The login portal has no external dependencies outside of GitHub and Kubernetes. All objects for session state are stored as CRDs.

Deployment

Watch a Video

This 7 minute video shows the entire deployment and user onboarding process

Alt text

What You Need To Start

Prior to deploying Orchestra you will need:

  1. Kubernetes 1.10 or higher
  2. The Nginx Ingress Controller deployed (https://kubernetes.github.io/ingress-nginx/deploy/)
  3. Client id and secret from a GitHub OAuth2 Application
  4. Deploy the dashboard to your cluster
  5. helm 3.0+

When creating your GitHub OAuth2 application, the callback URL ishttps://host_name/auth/github wherehost_name is the host you want to use for your login portal.

The deployment is a four step process:

  1. Add Tremolo Security's Helm repo to your own
  2. Deploy the OpenUnison Operator
  3. Create a secret for your Active Directory password
  4. Deploy OpenUnison

Add Tremolo Security's Helm Repo

helm repo add tremolo https://nexus.tremolo.io/repository/helm/helm repo update

Deploy The OpenUnison Operator

Create your namespace

kubectl create ns openunison

Deploy the operator

helm install openunison tremolo/openunison-operator --namespace openunison

Wait for the operator pod to be available

watch kubectl get pods -n openunison

Create A Secret For Your Active Directory Password

Create a secret in theopenunison namespace:

apiVersion: v1type: Opaquemetadata:  name: orchestra-secrets-source  namespace: openunisondata:  GITHUB_SECRET_ID: aW0gYSBzZWNyZXQ=  K8S_DB_SECRET: aW0gYSBzZWNyZXQ=  unisonKeystorePassword: aW0gYSBzZWNyZXQ=kind: Secret
PropertyDescription
GITHUB_SECRET_IDThe secret from your GitHub OAuth2 application
unisonKeystorePasswordThe password for OpenUnison's keystore, should NOT contain an ampersand (&)
K8S_DB_SECRETA random string of characters used to secure the SSO process with the dashboard. This should be long and random, with no ampersands (&)

Deploy OpenUnison

Copyvalues.yaml (https://raw.githubusercontent.com/OpenUnison/helm-charts/master/openunison-k8s-login-github/values.yaml) and update as appropriate:

PropertyDescription
network.openunison_hostThe host name for OpenUnison. This is what user's will put into their browser to login to Kubernetes
network.dashboard_hostThe host name for the dashboard. This is what users will put into the browser to access to the dashboard.NOTE:network.openunison_host andnetwork.dashboard_host Bothnetwork.openunison_host andnetwork.dashboard_hostMUST point to OpenUnison
network.api_server_hostThe host name to use for the api server reverse proxy. This is whatkubectl will interact with to access your cluster.NOTE:network.openunison_host andnetwork.dashboard_host
network.k8s_urlThe URL for the Kubernetes API server
network.session_inactivity_timeout_secondsThe number of seconds of inactivity before the session is terminated, also the length of the refresh token's session
network.createIngressCertificateIf true (default), the operator will create a self signed Ingress certificate. Set to false if using an existing certificate or LetsEncrypt
network.force_redirect_to_tlsIftrue, all traffic that reaches OpenUnison over http will be redirected to https. Defaults totrue. Set tofalse when using an external TLS termination point, such as an istio sidecar proxy
network.ingress_typeThe type ofIngress object to create.nginx andistio is supported
network.ingress_annotationsAnnotations to add to theIngress object
network.ingress_certificateThe certificate that theIngress object should reference
network.istio.selectorsLabels that the istioGateway object will be applied to. Default isistio: ingressgateway
cert_template.ouTheOU attribute for the forward facing certificate
cert_template.oTheO attribute for the forward facing certificate
cert_template.lTheL attribute for the forward facing certificate
cert_template.stTheST attribute for the forward facing certificate
cert_template.cTheC attribute for the forward facing certificate
certs.use_k8s_cmTells the deployment system if you should use k8s' built in certificate manager. If your distribution doesn't support this (such as Canonical and Rancher), set this to false
myvd_config_pathThe path to the MyVD configuration file, unless being customized, useWEB-INF/myvd.conf
dashboard.namespaceThe namespace for the dashboard. For the 1.x dashboard this iskube-system, for the 2.x dashboard this iskubernetes-dashboard
dashboard.cert_nameThe name of the secret in the dashboard's namespace that stores the certificate for the dashboard
dashboard.labelThe label of the dashboard pod, this is used to delete the pod once new certificates are generated
dashboard.service_nameThe name of the service object for the dashboard
k8s_cluster_nameThe name of the cluster to use in the./kube-config. Defaults tokubernetes
imageThe name of the image to use
enable_impersonationIftrue, OpenUnison will run in impersonation mode. Instead of OpenUnison being integrated with Kubernetes via OIDC, OpenUnison will be a reverse proxy and impersonate users. This is useful with cloud deployments where oidc is not an option
monitoring.prometheus_service_accountThe prometheus service account to authorize access to the /monitoring endpoint
github.client_idThe client id from your OAuth2 application configuration
github.teamsA comma separated list of authorized teams and organizations. An organization is listed in the formatOrgName/ and a team in the formateOrgName/TeamName
network_policies.enabledIftrue, creates a deny-all network policy and additional policies based on below configurations
network_policies.ingress.enablediftrue, a policy will be created that allows access from theNamespace identified by thelabels
network_policies.ingress.labelsLabels for theNamespace hosting theIngress
network_policies.monitoring.enablediftrue, a policy will be created that allows access from theNamespace identified by thelabels to support monitoring
network_policies.monitoring.labelsLabels for theNamespace hosting monitoring
network_policies.apiserver.enablediftrue, a policy will be created that allows access from thekube-nsNamespace identified by thelabels
network_policies.apiserver.labelsLabels for theNamespace hosting the api server
services.enable_tokenrequestIftrue, the OpenUnisonDeployment will use theTokenRequest API instead of staticServiceAccount tokens. *** NOT AVAILABLE UNTIL OPENUNISON 1.0.21 ***
services.token_request_audienceThe audience expected by the API server *** NOT AVAILABLE UNTIL OPENUNISON 1.0.21 ***
services.token_request_expiration_secondsThe number of seconds TokenRequest tokens should be valid for, minimum 600 seconds *** NOT AVAILABLE UNTIL OPENUNISON 1.0.21 ***
services.node_selectorsannotations to use when choosing nodes to run OpenUnison, maps to theDeploymentnodeSelector
services.pullSecretThe name of theSecret that stores the pull secret for pulling the OpenUnison image
services.resources.requests.memoryMemory requested by OpenUnison
services.resources.requests.cpuCPU requested by OpenUnison
services.resources.limits.memoryMaximum memory allocated to OpenUnison
services.resources.limits.cpuMaximum CPU allocated to OpenUnison
openunison.replicasThe number of OpenUnison replicas to run, defaults to 1
openunison.non_secret_dataAdd additional non-secret configuration options, added to thenon_secret_data secrtion of theOpenUnison object
openunison.secretsAdd additional keys from theorchestra-secrets-sourceSecret
impersonation.use_jetstackiftrue, the operator will deploy an instance of JetStack's OIDC Proxy (https://github.com/jetstack/kube-oidc-proxy). Default isfalse
impersonation.jetstack_oidc_proxy_imageThe name of the image to use
impersonation.explicit_certificate_trustIftrue, oidc-proxy will explicitly trust thetls.crt key of theSecret named inimpersonation.ca_secret_name. Defaults totrue
impersonation.ca_secret_nameIfimpersonation.explicit_certificate_trust istrue, the name of the tlsSecret that stores the certificate for OpenUnison that the oidc proxy needs to trust. Defaults toou-tls-secret
impersonation.resources.requests.memoryMemory requested by oidc proxy
impersonation.resources.requests.cpuCPU requested by oidc proxy
impersonation.resources.limits.memoryMaximum memory allocated to oidc proxy
impersonation.resources.limits.cpuMaximum CPU allocated to oidc proxy

Additionally, you can add your identity provider's TLS base64 encoded PEM certificate to your values undertrusted_certs forpem_b64. This will allow OpenUnison to talk to your identity provider using TLS if it doesn't use a commercially signed certificate. If you don't need a certificate to talk to your identity provider, replace thetrusted_certs section withtrusted_certs: [].

Finally, run the helm chart:

helm install orchestra tremolo/openunison-k8s-login-github --namespace openunison -f /path/to/values.yaml

Complete SSO Integration with Kubernetes

Runkubectl describe configmap api-server-config -n openunison to get the SSO integration artifacts. The output will give you both the API server flags that need to be configured on your API servers. The certificate that needs to be trusted is in theou-tls-certificate secret in theopenunison namespace.

First Login

To login, open your browser and go to the host you specified forOU_HOST in yourinput.props. For instance ifOU_HOST isk8sou.tremolo.lan then navigate tohttps://k8sou.tremolo.lan. You'll be prompted for your github username and password. Once authenticated you'll be able login to the portal and generate your.kube/config from the Tokens screen.

CLI Login

You can bypass manually launching a browser with theoulogin kubectl plugin -https://github.com/TremoloSecurity/kubectl-login. This plugin will launch a browser for you, authenticate you then configure your kubectl configuration without any pre-configuration on your clients.

Enabling JetStack OIDC Proxy for Impersonation

OpenUnison's built in reverse proxy doesn't support the SPDY protocol which kubectl, and the client-go sdk, uses forexec,cp, andport-forward. If you require these options, and are using impersonation, you can now enable the JetStack OIDC proxy (https://github.com/jetstack/kube-oidc-proxy) instead of using OpenUnison's built in reverse proxy. To enable it, add theimpersonation options from the helm chart configuration to your chart.NOTE when using the oidc-proxyservices.enable_tokenrequest must befalse. TheDeployment created for the oidc proxy will inherrit theServiceAccount from OpenUnison, as well as theservices.pullSecret andservices.node_selectors configuration in your helm chart. Resource requests and limits should be set specifically for the OIDC proxy under theimpersonation section. The proxy is run as a non-privileged unix user as well. An example configuration when deploying with Let's Encrypt:

impersonation:  use_jetstack: true  jetstack_oidc_proxy_image: quay.io/jetstack/kube-oidc-proxy:v0.3.0  explicit_certificate_trust: false

Authorizing Access via RBAC

On first login, if you haven't authorized access to any Kubernetes roles you won't be able to do anything. There are two approaches you can take:

Organization / Team Driven Membership

Kubernetes will see your user's organizations and teams as groups. To authorize users based on these groups, list them in your RBAC policies as groups with organizations being in the formatOrgName/ and teams being the formatOrgName/TeamName. To authorize members of teamTremnoloSecurity/Ownsers to be cluster administrators, we create aClusterRoleBinding:

kind: ClusterRoleBindingapiVersion: rbac.authorization.k8s.io/v1metadata:  name: github-cluster-adminssubjects:- kind: Group  name: TremoloSecurity/OwnersroleRef:  kind: ClusterRole  name: cluster-admin  apiGroup: rbac.authorization.k8s.io

User Driven Membership

If you are not able to use teams or organizations in GitHub, you can directly add users to role bindings. Kubernetes requires that you identify openid connect users with the prefix of the url of the identity provider. So if yourOU_HOST isk8sou.tremolo.lan and your user's login ismmosley your username to Kubernetes would behttps://k8sou.tremolo.lan/auth/idp/k8sIdp#mmosley. To create a cluster role binding to give cluster-admin access to a specific user:

kind: ClusterRoleBindingapiVersion: rbac.authorization.k8s.io/v1metadata:  name: github-cluster-adminssubjects:- kind: User  name: https://k8sou.tremolo.lan/auth/idp/k8sIdp#mmosleyroleRef:  kind: ClusterRole  name: cluster-admin  apiGroup: rbac.authorization.k8s.io

NOTE: There are multiple reasons this is a bad idea:

  1. Hard to audit - There is no easy way to say "what role bindings ismmosley a member of?
  2. Difficult to remove access - Same reason as #1, you need to figure out every role binding a user is a member of to remove
  3. Easy to get wrong - If you mistype a user's login id Kubernetes won't tell you

If you can't use github orgnization and teams, take a look at the OpenUnison Identity Manager for Kubernetes -https://github.com/TremoloSecurity/openunison-qs-kubernetes/tree/activedirectory. This tool adds on to the login capabilities with the ability to manage access to the cluster and namespaces, along with providing a self service way for users to request new namespaces and manage access.

Adding Applications and Clusters for Authentication

OpenUnison can support more applications for SSO then just Kubernetes and the dashboard. You can add other clusters and applications that support OpenID Connect by adding some custom resources to youropenunison namespace.

Add a Trust

TheTrust tells your OpenID Connect enabled application it can trust authentication requests from your OpenUnison. To start you'll need:

  1. Callback URL - This URL is where OpenUnison redirects the user after authenticating.
  2. Client Secret - Web applications, like GitLab, will need a secret that is shared between the two systems. Applications with CLI components, like ArgoCD, don't need a client secret.
  3. Client ID - This is how you identify your application to OpenUnison.

OpenUnison will provide the following claims for your application to consume:

ClaimDescription
subUnique identifier as supplied from authentication
nameCombination of first name and last name
preferred_usernameA username supplied from authentication
emailThe user's email address
groupsThe list of groups provided by the authentication source

Once you have everything you need to get started, create theTrust object.

Create a Secret

If you're application is using a client secret, aSecret needs to be created to hold it. This can either be a newSecret or it can be a new one. Which everSecret you add it to, keep a note of the name of theSecret and the key in thedata section used to store it.

If your application doesn't have a client secret, skip this step.

Create theTrust

Create aTrust object in theopenunison namespace. Here's one for GitLab you can use as an example:

apiVersion: openunison.tremolo.io/v1kind: Trustmetadata:  name: gitlab  namespace: openunisonspec:  accessTokenSkewMillis: 120000  accessTokenTimeToLive: 60000  authChainName: LoginService  clientId: gitlab  clientSecret:    keyName: gitlab    secretName: orchestra-secrets-source  codeLastMileKeyName: lastmile-oidc  codeTokenSkewMilis: 60000  publicEndpoint: false  redirectURI:  - https://gitlab.local.tremolo.dev/users/auth/openid_connect/callback  signedUserInfo: false  verifyRedirect: true

Here are the details for each option:

OptionDesription
accessTokenSkewMillisMilliseconds milliseconds added to account for clock skew
accessTokenTimeToLiveTime an access token should live in milliseconds
authChainNameThe authentication chain to use for login, do not change
clientIdThe client id shared by your application
clientSecret.scretNameIf using a client secret, the name of theSecret storing the client secret
clientSecret.keyNameThe key in thedata section of theSecret storing the client secret
codeLastMileKeyNameThe name of the key used to encrypt the code token, do not change
codeTokenSkewMilisMilliseconds to add to code token lifetime to account for clock skew
publicEndpointIftrue, a client secret is required. Iffalse, no client secret is needed
redirectURIList of URLs that are authorized for callback. If a URL is provided by your application that isn't in this list SSO will fail
signedUserInfoiftrue, the userinfo endpoint will return a signed JSON Web Token. Iffalse it will return plain JSON
verifyRedirectIftrue, the redirect URL provided by the clientMUST be listed in theredirectURI section. ShouldALLWAYS betrue if not in a development environment

Once theTrust is added to the namespace, OpenUnison will pick it up automatically. You can test by trying to login to your application.

Add a "Badge" to Your Portal

When you login to the Orchestra portal, there are badges for your tokens and for the dashboard. You can dynamically add a badge for your application too. Here's an examplePortalUrl object for ArgoCD:

apiVersion: openunison.tremolo.io/v1kind: PortalUrlmetadata:  name: argocs  namespace: openunisonspec:  label: ArgoCD  org: B158BD40-0C1B-11E3-8FFD-0800200C9A66  url: https://ArgoCD.apps.192-168-2-140.nip.io  icon: iVBORw0KGgoAAAANSUhEUgAAANIAAADwCAYAAAB1/Tp/AAAfQ3pUWHRSYXcgcHJvZ...  azRules:  - constraint: o=Tremolo    scope: dn
OptionDescriptoin
labelThe label shown on badge in the portal
orgIf using orgnaizations to organize badges, the uuid of the org. If not using organizations, leave as is
urlThe URL the badge should send the user to
iconA base64 encoded icon with a width of 210 pixels and a height of 240 pixels
azRulesWho is authorized to see this badge? Seehttps://portal.apps.tremolo.io/docs/tremolosecurity-docs/1.0.19/openunison/openunison-manual.html#_applications_applications for an explination of the authorization rules

Once created, the badge will appear in the Orchestra portal! No need to restart the containers.

Organizing Badges

If you're adding multiple badges or clusters, you may find that the number of badges on your front page become difficult to manage. In that case you can enable orgnaizations in OpenUnison and organize your badges using an orgnaization tree.

Enable Organizations on your Portal Page

Edit theorchestra object in theopenunison namespace (kubectl edit openunison orchestra -n openunison). Look for thenon_secret_data section and add the following:

- name: SHOW_PORTAL_ORGS  value: "true"

Once you save, OpenUnison will restart and when you login there will now be a tree that describes your organizations.

Orchestra with Organizations

Creating Organizations

Add anOrg object to theopenunison namespace. Here's an exampleOrg:

apiVersion: openunison.tremolo.io/v1kind: Orgmetadata:  name: cluster2  namespace: openunisonspec:  description: "My second cluster"  uuid: 04901973-5f4c-46d9-9e22-55e88e168776  parent: B158BD40-0C1B-11E3-8FFD-0800200C9A66  showInPortal: true  showInRequestAccess: false  showInReports: false  azRules:  - scope: dn    constraint: o=Tremolo
OptionDescription
descriptionWhat appears in the blue box describing the organization
uuidA unique ID, recommend using Type 4 UUIDs
parentThe unique id of the parent.B158BD40-0C1B-11E3-8FFD-0800200C9A66 is the root organization
showInPortalShould betrue
showInRequestAccessN/A
showInReportsN/A
azRulesWho is authorized to see this badge? Seehttps://portal.apps.tremolo.io/docs/tremolosecurity-docs/1.0.19/openunison/openunison-manual.html#_applications_applications for an explination of the authorization rules

Once added, the new organizations will be loaded dynamiclly by OpenUnison. Change theorg in yourPortalUrl object to match theuuid of theOrg you want it to appear in.

Using Your Own Certificates

If you want to integrate your own certificates see our wiki entry -https://github.com/TremoloSecurity/OpenUnison/wiki/troubleshooting#how-do-i-change-openunisons-certificates

Monitoring OpenUnison

This deployment comes with a/metrics endpoint for monitoring. For details on how to integrate it into a Prometheus stack -https://github.com/TremoloSecurity/OpenUnison/wiki/troubleshooting#how-do-i-monitor-openunison-with-prometheus.

Trouble Shooting Help

Please take a look athttps://github.com/TremoloSecurity/OpenUnison/wiki/troubleshooting if you're running into issues. If there isn't an entry there that takes care of your issue, please open an issue on this repo.

Whats next?

Now you can begin mapping OpenUnison's capabilities to your business and compliance needs. For instance you can add multi-factor authentication with TOTP or U2F, Create privileged workflows for onboarding, scheduled workflows that will deprovision users, etc.

Customizing Orchestra

To customize Orchestra -https://github.com/TremoloSecurity/OpenUnison/wiki/troubleshooting#customizing-orchestra

Examples

Using GitHub To Login to Kubernetes -https://www.tremolosecurity.com/post/using-github-to-access-kubernetes

About

Kubernetes login portal for both kubectl and the dashboard using GitHub. Use organizations and teams in RBAC policies to control access to your cluster. Supports impersonation and OpenID Connect integration with your API server.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp