buzzfeed-sso

by joaquinito2051

Helm chartv0.0.1App 1.1.0

Single sign-on for your Kubernetes services using Google OAuth

About this chart

Buzzfeed SSO

Single sign-on for your Kubernetes services using Google OAuth (more providers are welcomed)

Blogpost Quickstart guide SSO in Kubernetes with Google Auth Repo

This helm chart is heavily inspired in Buzzfeed's example, and provides a way of protecting Kubernetes services that have no authentication layer globally from a single OAuth proxy.

Many of the Kubernetes OAuth solutions require to run an extra container within the pod using oauth2_proxy, but the project seems to not be maintained anymore. The approach presented on this chart allows to have a global OAuth2 Proxy that can protect services even in different namespaces, thanks to Kube DNS.

We use this chart in production at MindDoc for protecting endpoints that have no built-in authentication (or that would require to run inner containers), like Kibana, Prometheus, etc...

Introduction

This chart creates a SSO deployment on a Kubernetes cluster using the Helm package manager.

Prerequisites

  • Kubernetes 1.8+ with Beta APIs enabled
  • Kube DNS

Installing the Chart

To install the chart with the release name my-release:

$ helm install --name my-release <helm-repo>/buzzfeed-sso

$ helm install --name my-release stable/buzzfeed-sso The command deploys SSO on the Kubernetes cluster using the default configuration. The configuration section lists the parameters that can be configured during installation.

This chart has required variables, see Configuration.

Uninstalling the Chart

To uninstall/delete the my-release deployment:

$ helm delete --purge my-release

The command removes all the Kubernetes components associated with the chart and deletes the release.

Configuration

The following table lists the configurable parameters of the SSO chart and their default/required values.

ParameterDescriptionDefault
namespacenamespace to usedefault
emailDomainthe sso email domain for authenticationREQUIRED
rootDomainthe parent domain used for protecting your backendsREQUIRED
auth.annotationsextra annotations for auth pods{}
auth.domainthe auth domain used for OAuth callbacksREQUIRED
auth.replicaCountdesired number of auth pods1
auth.resourcesresource limits and requests for auth pods{ limits: { memory: "256Mi", cpu: "200m" }}
auth.nodeSelectornode selector logic for auth pods{}
auth.tolerationsresource tolerations for auth pods{}
auth.affinitynode affinity for auth pods{}
auth.service.typetype of auth service to createClusterIP
auth.service.portport for the http auth service80
auth.secretsecrets to be generated randomly with `openssl rand -base64 32head -c 32`.
auth.tlstls configuration for central sso auth ingress.{ secretName: "sso-auth-tls-secret" }
auth.customSecretthe secret key to reuse (avoids secret creation via helm)REQUIRED if auth.secret is not set
proxy.annotationsextra annotations for proxy pods{}
proxy.providerUrlInternalurl for split dns deployments
proxy.clusterthe cluster name for SSOdev
proxy.replicaCountdesired number of proxy pods1
proxy.resourcesresource limits and requests for proxy pods{ limits: { memory: "256Mi", cpu: "200m" }}
proxy.nodeSelectornode selector logic for proxy pods{}
proxy.tolerationsresource tolerations for proxy pods{}
proxy.affinitynode affinity for proxy pods{}
proxy.service.typetype of proxy service to createClusterIP
proxy.service.portport for the http proxy service80
proxy.secretsecrets to be generated randomly with `openssl rand -base64 32head -c 32
proxy.customSecretthe secret key to reuse (avoids secret creation via helm)REQUIRED if proxy.secret is not set
provider.googlethe Oauth provider to use (only Google support for now)REQUIRED
provider.google.adminEmailthe Google admin emailundefined
provider.google.secretthe Google OAuth secretsREQUIRED if provider.google.customSecret is not set
provider.google.customSecretthe secret key to reuse instead of creating it via helmREQUIRED if provider.google.secret is not set
image.repositorycontainer image repositorybuzzfeed/sso
image.tagcontainer image tagv1.0.0
image.pullPolicycontainer image pull policyIfNotPresent
ingress.annotationsingress load balancer annotations{}
ingress.hostsproxied hosts[]
ingress.tlstls certificates for the proxied hosts[]
upstreamsconfiguration of services that use sso[]

Specify each parameter using the --set key=value[,key=value] argument to helm install. For example,

Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
$ helm install --name my-release \
    --set key_1=value_1,key_2=value_2 \
    <helm-repo>/buzzfeed-sso
$ helm install --name my-release \

Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,

$ helm install --name my-release -f values.yaml <helm-repo>/buzzfeed-sso

$ helm install --name my-release -f values.yaml stable/buzzfeed-sso

Tip: This will merge parameters with values.yaml, which does not specify all the required values

Example

NEVER expose your auth.secret, proxy.secret, provider.google.clientId, provider.google.clientSecret and provider.google.serviceAccount. Always keep them in a safe place and do not push them to any repository. As values are merged, you can always generate a different .yaml file. For instance:

# values.yaml
emailDomain: 'email.coolcompany.foo'

rootDomain: 'coolcompany.foo'

auth:
  domain: sso-auth.coolcompany.foo

proxy:
  cluster: dev

google:
  adminEmail: [email protected]
# secrets.yaml
auth:
 secret:
    codeSecret: 'randomSecret1'
    cookieSecret: 'randomSecret2'

proxy:
  secret:
    clientId: 'randomSecret3'
    clientSecret: 'randomSecret4'
    cookieSecret: 'randomSecret6'

google:
  secret:
    clientId: 'googleSecret!'
    clientSecret: 'evenMoreSecret'
    serviceAccount: '{ <json content super secret> }'

Therefore, you could push your own values.yaml to a repo and keep secrets.yaml locally safe, and then install/update the chart:

$ helm install --name my-release -f values.yaml -f secrets.yaml <helm-repo>/buzzfeed-sso

$ helm install --name my-release -f values.yaml -f secrets.yaml stable/buzzfeed-sso Alternatively, you can specify your own secret key, if you have already created it in the cluster. The secret should follow the data format defined in secret.yaml (auth and proxy) and google-secret.yaml (google provider).

# values.yaml
emailDomain: 'email.coolcompany.foo'

rootDomain: 'coolcompany.foo'

auth:
  domain: sso-auth.coolcompany.foo
  customSecret: my-sso-auth-secret

proxy:
  cluster: dev
  customSecret: my-sso-proxy-secret

provider:
  google:
    adminEmail: [email protected]
    customSecret: my-sso-google-secret

Updating the Chart

You can update the chart values and trigger a pod reload. If the configmap changes, it will automatically retrieve the new values.

$ helm upgrade -f values.yaml my-release stable/buzzfeed-sso

Deploy buzzfeed-sso with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has buzzfeed-sso on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartbuzzfeed-sso is pinned at v0.0.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply