Skip to content

Commit f262498

Browse files
authored
Add proxy support to Velero (#224)
* Add proxy support to Velero
1 parent 7640da8 commit f262498

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

controllers/helm.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,24 @@ func updateInfraChartsFromInstall(ctx context.Context, in *v1beta1.Installation,
204204

205205
charts[i].Values = newVals
206206
}
207+
if chart.Name == "velero" {
208+
if in.Spec.Proxy != nil {
209+
extraEnvVars := map[string]interface{}{
210+
"extraEnvVars": map[string]string{
211+
"HTTP_PROXY": in.Spec.Proxy.HTTPProxy,
212+
"HTTPS_PROXY": in.Spec.Proxy.HTTPSProxy,
213+
"NO_PROXY": in.Spec.Proxy.NoProxy,
214+
},
215+
}
216+
217+
newVals, err := setHelmValue(chart.Values, "configuration", extraEnvVars)
218+
if err != nil {
219+
log.Error(err, "failed to set helm values extraEnvVars", "chart", chart.Name)
220+
continue
221+
}
222+
charts[i].Values = newVals
223+
}
224+
}
207225
}
208226
return charts
209227
}

controllers/helm_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,36 @@ func Test_updateInfraChartsFromInstall(t *testing.T) {
14251425
},
14261426
},
14271427
},
1428+
{
1429+
name: "velero with proxy",
1430+
args: args{
1431+
in: &v1beta1.Installation{
1432+
Spec: v1beta1.InstallationSpec{
1433+
ClusterID: "testid",
1434+
BinaryName: "testbin",
1435+
AirGap: false,
1436+
HighAvailability: false,
1437+
Proxy: &v1beta1.ProxySpec{
1438+
HTTPProxy: "http://proxy",
1439+
HTTPSProxy: "https://proxy",
1440+
NoProxy: "noproxy",
1441+
},
1442+
},
1443+
},
1444+
charts: []k0sv1beta1.Chart{
1445+
{
1446+
Name: "velero",
1447+
Values: "abc: xyz\nconfiguration:\n extraEnvVars: {}\n",
1448+
},
1449+
},
1450+
},
1451+
want: []k0sv1beta1.Chart{
1452+
{
1453+
Name: "velero",
1454+
Values: "abc: xyz\nconfiguration:\n extraEnvVars:\n HTTP_PROXY: http://proxy\n HTTPS_PROXY: https://proxy\n NO_PROXY: noproxy\n",
1455+
},
1456+
},
1457+
},
14281458
{
14291459
name: "docker-registry",
14301460
args: args{

0 commit comments

Comments
 (0)