concept STS Deployment in category microservice

appears as: STS Deployment
Microservices Security in Action

This is an excerpt from Manning's book Microservices Security in Action.

Listing 11.9 modifies the STS Deployment to load keystore.jks and jwt.jks files from a Git repository by using an init container instead of loading them from a ConfigMap object (as in listing 11.8). You can find the complete updated definition of the Kubernetes Deployment in the chapter11/sample01/sts.deployment.with.initcontainer.yaml file. The following listing shows part of the updated STS deployment, corresponding to the init container.

In this section, we create a service account called ecomm, and update the STS Deployment to use it. We want all the Pods running under the STS Deployment to run under the ecomm service account. Let’s use the following kubectl command to create the ecomm service account:

\> kubectl create serviceaccount ecomm


serviceaccount/ecomm created

At the time of creating the service account, Kubernetes also creates a token secret and attaches it to the service account. When we update the STS Deployment to run under the ecomm service account, all the Pods under the STS Deployment can use this token secret (which is a JWT) to authenticate to the API server. The following command shows the details of the ecomm service account in YAML format:

\> kubectl get  serviceaccount ecomm -o  yaml


apiVersion: v1
kind: ServiceAccount
metadata:
  name: ecomm
  namespace: default
secrets:
- name: ecomm-token-92p7g

Now let’s set the ecomm service account for the STS Deployment. The complete up-dated definition of the STS Deployment is in the chapter11/sample01/sts.deployment .with.service.account.yaml file. We are introducing these new changes on top of the STS Deployment created in section 11.3.2. As shown in the following listing, the only change was to add the serviceAccountName element under the spec element (corresponding to the Pod) of the Deployment.