Kubernetes service account custom token

9/22/2017

I am trying to create a service account with a known, fixed token used by Jenkins to deploy stuff into kubernetes. I manage to create the token all right with the following yaml:

apiVersion: v1
kind: Secret
metadata:
  name: integration-secret
  annotations:
    kubernetes.io/service-account.name: integration
type: kubernetes.io/service-account-token
data:
  token: YXNkCg== # yes this base64

Then I've attached the secret to 'integration' user and it's visible:

-> kubectl describe sa integration
Name:       integration
Namespace:  default
Labels:     <none>
Annotations:    <none>

Mountable secrets:  integration-secret
                    integration-token-283k9

Tokens:             integration-secret
                    integration-token-283k9

Image pull secrets: <none>

But the login fails. If i remove the data and data.token, the token get auto-created and login works. Is there something I'm missing? My goal is to have fixed token for CI so that I won't have to update it everywhere when creating a project (don't worry this is just dev environments). Is it possible for example to define username/password for service accounts for API access?

-- user2170710
kubernetes
openshift

1 Answer

9/22/2017

Is it possible for example to define username/password for service accounts for API access?

No, the tokens must be valid JWTs, signed by the service account token signing key.

-- Jordan Liggitt
Source: StackOverflow