Merge pull request #1881 from PROCYDE/k8s-service-account-token-mounting

k8s: dont mount service account tokens to apps
This commit is contained in:
Aditya
2025-11-19 15:41:46 +05:30
committed by GitHub
3 changed files with 13 additions and 15 deletions
@@ -1558,15 +1558,6 @@ app:
##
annotations: {}
## @param app.serviceAccount.automountServiceAccountToken Automount service account token for the app service account
## NOTE: You likely want to allow access to cluster-proxies, e.g:
## extraEgress:
## - to:
## - namespaceSelector:
## matchLabels:
## kubernetes.io/metadata.name: istio-system
## podSelector:
## matchLabels:
## istio: pilot
##
automountServiceAccountToken: true
## @param app.serviceAccount.imagePullSecrets Add image pull secrets to the app service account
+7 -3
View File
@@ -1426,6 +1426,9 @@ func deployK8sWorker(image string, identifier string, env []string) error {
}
replicaNumberInt32 := int32(replicaNumber)
// worker makes authenticated requests to the k8s api to create app deployments.
// Therefore, it needs to have access to the service account token.
automountServiceAccountToken := true
deployment := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
@@ -1445,9 +1448,10 @@ func deployK8sWorker(image string, identifier string, env []string) error {
Containers: []corev1.Container{
containerAttachment,
},
DNSPolicy: corev1.DNSClusterFirst,
ServiceAccountName: workerServiceAccountName,
SecurityContext: podSecurityContext,
DNSPolicy: corev1.DNSClusterFirst,
ServiceAccountName: workerServiceAccountName,
AutomountServiceAccountToken: &automountServiceAccountToken,
SecurityContext: podSecurityContext,
},
},
},
+6 -3
View File
@@ -625,6 +625,8 @@ func deployk8sApp(image string, identifier string, env []string) error {
}
replicaNumberInt32 := int32(replicaNumber)
// apps do not need access the k8s api.
automountServiceAccountToken := false
deployment := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
@@ -656,9 +658,10 @@ func deployk8sApp(image string, identifier string, env []string) error {
Resources: buildResourcesFromEnv(),
},
},
DNSPolicy: corev1.DNSClusterFirst,
ServiceAccountName: appServiceAccountName,
SecurityContext: podSecurityContext,
DNSPolicy: corev1.DNSClusterFirst,
ServiceAccountName: appServiceAccountName,
AutomountServiceAccountToken: &automountServiceAccountToken,
SecurityContext: podSecurityContext,
},
},
},