scale test service account token projection in kubemark

This commit is contained in:
Mike Danese
2018-10-22 21:24:36 -07:00
parent e463d10935
commit 7613482623
4 changed files with 101 additions and 24 deletions

View File

@@ -172,6 +172,8 @@ type RCConfig struct {
// Names of the secrets and configmaps to mount.
SecretNames []string
ConfigMapNames []string
ServiceAccountTokenProjections int
}
func (rc *RCConfig) RCConfigLog(fmt string, args ...interface{}) {
@@ -322,6 +324,10 @@ func (config *DeploymentConfig) create() error {
attachConfigMaps(&deployment.Spec.Template, config.ConfigMapNames)
}
for i := 0; i < config.ServiceAccountTokenProjections; i++ {
attachServiceAccountTokenProjection(&deployment.Spec.Template, fmt.Sprintf("tok-%d", i))
}
config.applyTo(&deployment.Spec.Template)
if err := CreateDeploymentWithRetries(config.Client, config.Namespace, deployment); err != nil {
@@ -1241,6 +1247,57 @@ func attachConfigMaps(template *v1.PodTemplateSpec, configMapNames []string) {
template.Spec.Containers[0].VolumeMounts = mounts
}
func attachServiceAccountTokenProjection(template *v1.PodTemplateSpec, name string) {
template.Spec.Containers[0].VolumeMounts = append(template.Spec.Containers[0].VolumeMounts,
v1.VolumeMount{
Name: name,
MountPath: "/var/service-account-tokens/" + name,
})
template.Spec.Volumes = append(template.Spec.Volumes,
v1.Volume{
Name: name,
VolumeSource: v1.VolumeSource{
Projected: &v1.ProjectedVolumeSource{
Sources: []v1.VolumeProjection{
{
ServiceAccountToken: &v1.ServiceAccountTokenProjection{
Path: "token",
Audience: name,
},
},
{
ConfigMap: &v1.ConfigMapProjection{
LocalObjectReference: v1.LocalObjectReference{
Name: "kube-root-ca-crt",
},
Items: []v1.KeyToPath{
{
Key: "ca.crt",
Path: "ca.crt",
},
},
},
},
{
DownwardAPI: &v1.DownwardAPIProjection{
Items: []v1.DownwardAPIVolumeFile{
{
Path: "namespace",
FieldRef: &v1.ObjectFieldSelector{
APIVersion: "v1",
FieldPath: "metadata.namespace",
},
},
},
},
},
},
},
},
})
}
type DaemonConfig struct {
Client clientset.Interface
Name string