Difference between revisions of "Tutorials:Set up your Kubernetes user account"

From Collective Computational Unit
Jump to navigation Jump to search
m (Set up a .kube/config file)
m (Set up a .kube/config file)
Line 11: Line 11:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Create a file ".kube/config" and edit its contents as follows:
+
Create a file ".kube/config" and edit its contents as follows. To make sure you get the certificate authority data right, better download it here: [[File:kubeconfig_template_ccu]].
  
 
<syntaxhighlight lang="yaml">
 
<syntaxhighlight lang="yaml">
Line 28: Line 28:
 
     cluster: ccu
 
     cluster: ccu
 
     namespace: tf-test
 
     namespace: tf-test
     user: bastian.goldluecke
+
     user: your.username
   name: kubernetes-admin@ccu
+
   name: me@ccu
 
current-context: ccu
 
current-context: ccu
 
kind: Config
 
kind: Config
 
preferences: {}
 
preferences: {}
 
users:
 
users:
- name: bastian.goldluecke
+
- name: your.username
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Revision as of 06:41, 6 June 2019

Unfortunately, making your identity known to the cluster on any machine is a decidedly manual process, which involves editing a local configuration that resides in ".kube/config".

Set up a .kube/config file

Create the subdirectory ".kube" in your home and set restrictive permissions. It will contain your cluster credentials, and anyone who has access to the files in there can steal your identity and impersonate you. We do not want this.

> cd ~
> mkdir .kube
> chmod 700 .kube

Create a file ".kube/config" and edit its contents as follows. To make sure you get the certificate authority data right, better download it here: File:Kubeconfig template ccu.

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRFNU1EVXlOekUwTWpBeU5Gb1hEVEk1TURVeU5ERTBNakF5TkZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTGk0Ck01bTN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UNBVEUtLS0tLQo=
    server: https://ccu.uni-konstanz.de:6443
  name: ccu
contexts:
- context:
    cluster: ""
    user: ""
  name: ccu
- context:
    cluster: ccu
    namespace: tf-test
    user: your.username
  name: me@ccu
current-context: ccu
kind: Config
preferences: {}
users:
- name: your.username

Of course, substitute your own username at the indicated locations.

Get your user credentials (an OAuth ID token) from our server

The next step is to authenticate against our server, which will then create a credential (basically a secret token which only you should know) so that you can prove to the cluster that you are indeed who you claim you are. Go to [] and enter your CCU login. You will get something like this in return:


Copy your credentials to the config and enter the CCU context

Finally, copy paste the above output from your web browser to your ".kube/config" so that it looks like this:

If you have some background in programming, the structure of the config file should be pretty obvious, and you will be able to extend it to include e.g. multiple identities and contexts which access different namespaces. This is quite useful for quickly switching between them without having to type so much.