k8s: dont mount service account tokens to apps
Signed-off-by: Pascal Sthamer <10992664+P4sca1@users.noreply.github.com>
This commit is contained in:
@@ -1426,6 +1426,9 @@ func deployK8sWorker(image string, identifier string, env []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
replicaNumberInt32 := int32(replicaNumber)
|
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{
|
deployment := &appsv1.Deployment{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
@@ -1445,9 +1448,10 @@ func deployK8sWorker(image string, identifier string, env []string) error {
|
|||||||
Containers: []corev1.Container{
|
Containers: []corev1.Container{
|
||||||
containerAttachment,
|
containerAttachment,
|
||||||
},
|
},
|
||||||
DNSPolicy: corev1.DNSClusterFirst,
|
DNSPolicy: corev1.DNSClusterFirst,
|
||||||
ServiceAccountName: workerServiceAccountName,
|
ServiceAccountName: workerServiceAccountName,
|
||||||
SecurityContext: podSecurityContext,
|
AutomountServiceAccountToken: &automountServiceAccountToken,
|
||||||
|
SecurityContext: podSecurityContext,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -625,6 +625,8 @@ func deployk8sApp(image string, identifier string, env []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
replicaNumberInt32 := int32(replicaNumber)
|
replicaNumberInt32 := int32(replicaNumber)
|
||||||
|
// apps do not need access the k8s api.
|
||||||
|
automountServiceAccountToken := false
|
||||||
|
|
||||||
deployment := &appsv1.Deployment{
|
deployment := &appsv1.Deployment{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
@@ -656,9 +658,10 @@ func deployk8sApp(image string, identifier string, env []string) error {
|
|||||||
Resources: buildResourcesFromEnv(),
|
Resources: buildResourcesFromEnv(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
DNSPolicy: corev1.DNSClusterFirst,
|
DNSPolicy: corev1.DNSClusterFirst,
|
||||||
ServiceAccountName: appServiceAccountName,
|
ServiceAccountName: appServiceAccountName,
|
||||||
SecurityContext: podSecurityContext,
|
AutomountServiceAccountToken: &automountServiceAccountToken,
|
||||||
|
SecurityContext: podSecurityContext,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user