Skip to content

Commit

Permalink
fixup! Add kubernetes host to the no proxy list
Browse files Browse the repository at this point in the history
  • Loading branch information
vinokurig committed Jan 18, 2024
1 parent a63ceed commit 711e1c0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
20 changes: 14 additions & 6 deletions controllers/che/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ func GetProxyConfiguration(deployContext *chetypes.DeployContext) (*chetypes.Pro
return nil, err
}

// Add kubernetes host to the no proxy list.
cheClusterProxyConf.NoProxy = deploy.MergeNonProxy(cheClusterProxyConf.NoProxy, os.Getenv("KUBERNETES_SERVICE_HOST"))

// If proxy configuration exists in CR then cluster wide proxy configuration is ignored
// Non proxy hosts are merged
if cheClusterProxyConf.HttpProxy != "" {
Expand All @@ -54,10 +51,17 @@ func GetProxyConfiguration(deployContext *chetypes.DeployContext) (*chetypes.Pro
}
// Add cluster-wide trusted CA certs, if any
cheClusterProxyConf.TrustedCAMapName = clusterWideProxyConf.TrustedCAMapName
// Add kubernetes host to the no proxy list.
cheClusterProxyConf.NoProxy = deploy.MergeNonProxy(cheClusterProxyConf.NoProxy, os.Getenv("KUBERNETES_SERVICE_HOST"))
return cheClusterProxyConf, nil
} else {
clusterWideProxyConf.NoProxy = deploy.MergeNonProxy(clusterWideProxyConf.NoProxy, cheClusterProxyConf.NoProxy)
return clusterWideProxyConf, nil
// add openshift conf check
if clusterWideProxyConf.HttpProxy != "" {
// Add kubernetes host to the no proxy list.
cheClusterProxyConf.NoProxy = deploy.MergeNonProxy(cheClusterProxyConf.NoProxy, os.Getenv("KUBERNETES_SERVICE_HOST"))
clusterWideProxyConf.NoProxy = deploy.MergeNonProxy(clusterWideProxyConf.NoProxy, cheClusterProxyConf.NoProxy)
return clusterWideProxyConf, nil
}
}
}

Expand All @@ -66,6 +70,10 @@ func GetProxyConfiguration(deployContext *chetypes.DeployContext) (*chetypes.Pro
if err != nil {
return nil, err
}
cheClusterProxyConf.NoProxy = deploy.MergeNonProxy(cheClusterProxyConf.NoProxy, ".svc")
if cheClusterProxyConf.HttpProxy != "" {
// Add kubernetes host to the no proxy list.
cheClusterProxyConf.NoProxy = deploy.MergeNonProxy(cheClusterProxyConf.NoProxy, os.Getenv("KUBERNETES_SERVICE_HOST"))
cheClusterProxyConf.NoProxy = deploy.MergeNonProxy(cheClusterProxyConf.NoProxy, ".svc")
}
return cheClusterProxyConf, nil
}
4 changes: 3 additions & 1 deletion pkg/deploy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ func ReadCheClusterProxyConfiguration(ctx *chetypes.DeployContext) (*chetypes.Pr
}

func MergeNonProxy(noProxy1 string, noProxy2 string) string {
if noProxy1 == "" {
if noProxy1 == "" && noProxy2 == "" {
return ""
} else if noProxy1 == "" {
return noProxy2
} else if noProxy2 == "" {
return noProxy1
Expand Down

0 comments on commit 711e1c0

Please sign in to comment.