1
0
mirror of https://github.com/rancher/rke.git synced 2025-08-31 14:36:32 +00:00

Use initContainer for nginx ingress if it is old version

**Problem:**
The nginx ingress daemonSet securityContext can not be applied to
version before 0.16.0

**Solution:**
When the nginx controller version is older than 0.16.0, we use the old
way to set it up.
This commit is contained in:
orangedeng
2019-01-29 21:30:26 +08:00
committed by Alena Prokharchyk
parent 3094ac132d
commit 642970feb2
2 changed files with 24 additions and 0 deletions

View File

@@ -439,6 +439,16 @@ func (c *Cluster) deployIngress(ctx context.Context) error {
IngressImage: c.SystemImages.Ingress,
IngressBackend: c.SystemImages.IngressBackend,
}
// since nginx ingress controller 0.16.0, it can be run as non-root and doesn't require privileged anymore.
// So we can use securityContext instead of setting privileges via initContainer.
ingressSplits := strings.SplitN(c.SystemImages.Ingress, ":", 2)
if len(ingressSplits) == 2 {
version := strings.Split(ingressSplits[1], "-")[0]
if version < "0.16.0" {
ingressConfig.AlpineImage = c.SystemImages.Alpine
}
}
// Currently only deploying nginx ingress controller
ingressYaml, err := addons.GetNginxIngressManifest(ingressConfig)
if err != nil {