Browse Source

0.0.6 mount configmaps and secrets

tags/0.0.6
Vladimir Smagin 2 months ago
parent
commit
99fc9b4695
5 changed files with 81 additions and 3 deletions
  1. +8
    -0
      README.md
  2. +1
    -1
      VERSION
  3. +15
    -1
      pkg/apis/blindage/v1alpha1/cronop_types.go
  4. +56
    -0
      pkg/controller/cronop/cronjob.go
  5. +1
    -1
      version/version.go

+ 8
- 0
README.md View File

@@ -37,6 +37,14 @@ This parameters can be set in global section or each task:
- Set Configmap with ENV variables
`envConfigmap`: _default empty_

- Mount secrets or configmaps to specified path, globally and/or job local
```
MountConfigmap string `json:"mountConfigmap,omitempty"` // Mount configmap as files, default empty
MountConfigmapPath string `json:"mountConfigmapPath,omitempty"` // by default mounts to /configmap-local
MountSecret string `json:"mountSecret,omitempty"` // Mount secret as files, default empty
MountSecretPath string `json:"mountSecretPath,omitempty"` // by default mounts to /secret-local
```

- How to restart Pod
`restartPolicy`: **OnFailure** | *Never* | *Always*



+ 1
- 1
VERSION View File

@@ -1 +1 @@
0.0.5.1
0.0.6

+ 15
- 1
pkg/apis/blindage/v1alpha1/cronop_types.go View File

@@ -19,6 +19,13 @@ type CronTask struct {
EnvConfigmap string `json:"envConfigmap,omitempty"` // default empty, overrides global configmap
BackoffLimit *int32 `json:"backoffLimit,omitempty"` // default 0, overrides global limit
PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"` // default empty, overrides global context

// Use it if you want provide some secrets or config files
MountConfigmap string `json:"mountConfigmap,omitempty"` // Mount configmap as files, default empty
MountConfigmapPath string `json:"mountConfigmapPath,omitempty"` // by default mounts to /configmap-local
MountSecret string `json:"mountSecret,omitempty"` // Mount secret as files, default empty
MountSecretPath string `json:"mountSecretPath,omitempty"` // by default mounts to /secret-local

}

type CronOpSpec struct {
@@ -30,7 +37,14 @@ type CronOpSpec struct {
FailedJobsHistoryLimit *int32 `json:"failedJobsHistoryLimit,omitempty"` // default 3
BackoffLimit *int32 `json:"backoffLimit,omitempty"` // default 0, global

EnvConfigmap string `json:"envConfigmap,omitempty"` // default empty, global
EnvConfigmap string `json:"envConfigmap,omitempty"` // default empty, global

// Use it if you want provide some secrets or config files
MountConfigmap string `json:"mountConfigmap,omitempty"` // Mount configmap as files, default empty
MountConfigmapPath string `json:"mountConfigmapPath,omitempty"` // by default mounts to /configmap-global
MountSecret string `json:"mountSecret,omitempty"` // Mount secret as files, default empty
MountSecretPath string `json:"mountSecretPath,omitempty"` // by default mounts to /secret-global

PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"`

PersistentVolumeName string `json:"persistentVolumeName,omitempty"` // default emtpy, must be created before use


+ 56
- 0
pkg/controller/cronop/cronjob.go View File

@@ -203,6 +203,62 @@ func generateCronjob(reqLogger logr.Logger, cr *blindagev1alpha1.CronOp, jobSpec

}

// Mount configmaps

if cr.Spec.MountConfigmap != "" {
// Set mount point
mountPath := "/configmap-global"
if jobSpec.MountConfigmapPath != "" {
mountPath = cr.Spec.MountConfigmapPath
}
volumeMount := corev1.VolumeMount{
Name: "configmap-global",
MountPath: mountPath,
}
jobContainer.VolumeMounts = append(jobContainer.VolumeMounts, volumeMount)
}

if jobSpec.MountConfigmap != "" {
// Set mount point
mountPath := "/configmap-local"
if jobSpec.MountConfigmapPath != "" {
mountPath = jobSpec.MountConfigmapPath
}
volumeMount := corev1.VolumeMount{
Name: "configmap-local",
MountPath: mountPath,
}
jobContainer.VolumeMounts = append(jobContainer.VolumeMounts, volumeMount)
}

// Mount secrets

if cr.Spec.MountSecret != "" {
// Set mount point
mountPath := "/secret-global"
if jobSpec.MountSecretPath != "" {
mountPath = cr.Spec.MountSecretPath
}
volumeMount := corev1.VolumeMount{
Name: "secret-global",
MountPath: mountPath,
}
jobContainer.VolumeMounts = append(jobContainer.VolumeMounts, volumeMount)
}

if jobSpec.MountSecret != "" {
// Set mount point
mountPath := "/secret-local"
if jobSpec.MountSecretPath != "" {
mountPath = jobSpec.MountSecretPath
}
volumeMount := corev1.VolumeMount{
Name: "secret-local",
MountPath: mountPath,
}
jobContainer.VolumeMounts = append(jobContainer.VolumeMounts, volumeMount)
}

cronjob.Spec.JobTemplate.Spec.Template.Spec.Containers = []corev1.Container{jobContainer}

return cronjob


+ 1
- 1
version/version.go View File

@@ -1,5 +1,5 @@
package version

var (
Version = "0.0.5.1"
Version = "0.0.6"
)

Loading…
Cancel
Save