It’s My HomeLab - Why Do I Need SSO?

A presentation at Conf42 KubeNative in October 2022 in by Matt Williams

Slide 1

Slide 1

It’s My HomeLab Why Would I Want SSO? Matt Williams – Evangelist @ Infra matt@infrahq.com | @technovangelist

Slide 2

Slide 2

It’s My HomeLab Why Would I Want Single Sign On? Or Roles? Or Users? * Specific to Kubernetes Matt Williams – Evangelist @ Infra matt@infrahq.com | @technovangelist

Slide 3

Slide 3

A HomeLab can be whatever you want it to be.

Slide 4

Slide 4

Slide 5

Slide 5

A HomeLab can be made of whatever you have

Slide 6

Slide 6

My first HomeLab was…

Slide 7

Slide 7

My HomeLab Today

Slide 8

Slide 8

Slide 9

Slide 9

Slide 10

Slide 10

Slide 11

Slide 11

Slide 12

Slide 12

Kubernetes in the HomeLab Can take advantage of a hodgepodge of machines

Slide 13

Slide 13

Kubernetes in the HomeLab Consistent Deployments

Slide 14

Slide 14

Why Users and Roles in K8S at Home?

Slide 15

Slide 15

Kubernetes: What is a User? They don’t exist - or – • A signed certificate in a kubeconfig file •

Slide 16

Slide 16

apiVersion: v1 clusters: - cluster: certificate-authority-data: certgoeshere server: https://clusterendpoint.k8s.ondigitalocean.com name: mycluster contexts: - context: cluster: mycluster user: do-sfo3-matt-primary-admin name: mycontext current-context: mycontext kind: Config preferences: {} users: - name: do-sfo3-matt-primary-admin user: token: dop_v1_dea9d7ff2b8eb092f53ffebogus31d2bd4602a62a19b5ac4

Slide 17

Slide 17

apiVersion: v1 clusters: - cluster: certificate-authority-data: certgoeshere server: https://clusterendpoint.k8s.ondigitalocean.com name: mycluster contexts: - context: cluster: mycluster user: do-sfo3-matt-primary-admin name: mycontext current-context: mycontext kind: Config preferences: {} users: - name: do-sfo3-matt-primary-admin user: token: dop_v1_dea9d7ff2b8eb092f53ffebogus31d2bd4602a62a19b5ac4

Slide 18

Slide 18

apiVersion: v1 clusters: - cluster: certificate-authority-data: certgoeshere server: https://clusterendpoint.k8s.ondigitalocean.com name: mycluster contexts: - context: cluster: mycluster user: do-sfo3-matt-primary-admin name: mycontext current-context: mycontext kind: Config preferences: {} users: - name: do-sfo3-matt-primary-admin user: token: dop_v1_dea9d7ff2b8eb092f53ffebogus31d2bd4602a62a19b5ac4

Slide 19

Slide 19

apiVersion: v1 clusters: - cluster: certificate-authority-data: certgoeshere server: https://clusterendpoint.k8s.ondigitalocean.com name: mycluster contexts: - context: cluster: mycluster user: do-sfo3-matt-primary-admin name: mycontext current-context: mycontext kind: Config preferences: {} users: - name: do-sfo3-matt-primary-admin user: token: dop_v1_dea9d7ff2b8eb092f53ffebogus31d2bd4602a62a19b5ac4

Slide 20

Slide 20

Kubernetes: What is a Role? • Defines the level of access a ‘user’ has to the cluster • • Resource Verb

Slide 21

Slide 21

Kubernetes: What is a Role? apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: marketing-dev labels: app.infrahq.com/include-role: “true” rules: - apiGroups: [“”] # “” indicates the core API group resources: [“pods”] verbs: [“get”, “watch”, “list”]

Slide 22

Slide 22

Kubernetes: What is a Role? apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: marketing-dev labels: app.infrahq.com/include-role: “true” rules: - apiGroups: [“”] # “” indicates the core API group resources: [“pods”] verbs: [“get”, “watch”, “list”]

Slide 23

Slide 23

Kubernetes: What is a Role? apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: marketing-dev labels: app.infrahq.com/include-role: “true” rules: - apiGroups: [“”] # “” indicates the core API group resources: [“pods”] verbs: [“get”, “watch”, “list”]

Slide 24

Slide 24

Kubernetes: What is a Role? apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: marketing-dev labels: app.infrahq.com/include-role: “true” rules: - apiGroups: [“”] # “” indicates the core API group resources: [“pods”] verbs: [“get”, “watch”, “list”]

Slide 25

Slide 25

How to create a User Create the user key (openssl genpkey…) • Create the CSR (openssl req –new) • Submit the CSR to the cluster (yaml) • Approve the request (kubectl certificate • approve…)

Slide 26

Slide 26

How to create a User Get the approved request (kubectl get csr…) • Build the kubeconfig (kubectl —kubeconfig • myuserconfig config set-credentials, kubectl -kubeconfig myuserconfig configset-context) • Then distribute the file https://infrahq.com/blog/how-to-create-users

Slide 27

Slide 27

How to create a User • And then repeat often • • ensure bad parties can’t access And redistribute

Slide 28

Slide 28

Just give everyone admin??? • What happens when User fired • User compromised • • Kubernetes is Remote Execution as a Service

Slide 29

Slide 29

Can we automate it?

Slide 30

Slide 30

Brendan Burns - AddUser • https://github.com/brendandburns/kub ernetes-adduser

Slide 31

Slide 31

What’s missing from the script • Key / Config file distribution

Slide 32

Slide 32

How about something easier?

Slide 33

Slide 33

Slide 34

Slide 34

Infra • Two deployment options Self Hosted • Use Infra Cloud (coming soon) •

Slide 35

Slide 35

Demo

Slide 36

Slide 36

Summary HomeLabs let you practice • You should be using Users/Roles/SSO with K8s • Users in K8s are hard • Infra is easy • Infra lets you do the hard stuff without much thinking •

Slide 37

Slide 37

It’s My HomeLab Why Would I Want SSO? Matt Williams – Evangelist @ Infra matt@infrahq.com | @technovangelist