Skip to content

Commit 7ca672b

Browse files
StrongMonkeybrandond
authored andcommitted
Customize api server port
Signed-off-by: Daishan Peng <daishan@acorn.io>
1 parent 9f2eeec commit 7ca672b

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

pkg/controllers/chart/chart.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ type Controller struct {
6868
jobCache batchcontroller.JobCache
6969
apply apply.Apply
7070
recorder record.EventRecorder
71+
apiServerPort string
7172
}
7273

7374
func Register(ctx context.Context,
74-
systemNamespace, managedBy string,
75+
systemNamespace, managedBy, apiServerPort string,
7576
k8s kubernetes.Interface,
7677
apply apply.Apply,
7778
recorder record.EventRecorder,
@@ -96,6 +97,7 @@ func Register(ctx context.Context,
9697
jobs: jobs,
9798
jobCache: jobCache,
9899
recorder: recorder,
100+
apiServerPort: apiServerPort,
99101
}
100102

101103
c.apply = apply.
@@ -309,7 +311,7 @@ func (c *Controller) getJobAndRelatedResources(chart *v1.HelmChart) (*batch.Job,
309311
}
310312

311313
// get the default job and configmaps
312-
job, valuesSecret, contentConfigMap := job(chart)
314+
job, valuesSecret, contentConfigMap := job(chart, c.apiServerPort)
313315

314316
// check if a HelmChartConfig is registered for this Helm chart
315317
config, err := c.confCache.Get(chart.Namespace, chart.Name)
@@ -340,7 +342,7 @@ func (c *Controller) getJobAndRelatedResources(chart *v1.HelmChart) (*batch.Job,
340342
}, nil
341343
}
342344

343-
func job(chart *v1.HelmChart) (*batch.Job, *corev1.Secret, *corev1.ConfigMap) {
345+
func job(chart *v1.HelmChart, apiServerPort string) (*batch.Job, *corev1.Secret, *corev1.ConfigMap) {
344346
jobImage := strings.TrimSpace(chart.Spec.JobImage)
345347
if jobImage == "" {
346348
jobImage = DefaultJobImage
@@ -481,7 +483,7 @@ func job(chart *v1.HelmChart) (*batch.Job, *corev1.Secret, *corev1.ConfigMap) {
481483
Value: "127.0.0.1"},
482484
{
483485
Name: "KUBERNETES_SERVICE_PORT",
484-
Value: "6443"},
486+
Value: apiServerPort},
485487
{
486488
Name: "BOOTSTRAP",
487489
Value: "true"},

pkg/controllers/chart/chart_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestSetVals(t *testing.T) {
3838
func TestInstallJob(t *testing.T) {
3939
assert := assert.New(t)
4040
chart := NewChart()
41-
job, _, _ := job(chart)
41+
job, _, _ := job(chart, "6443")
4242
assert.Equal("helm-install-traefik", job.Name)
4343
assert.Equal(DefaultJobImage, job.Spec.Template.Spec.Containers[0].Image)
4444
assert.Equal("helm-traefik", job.Spec.Template.Spec.ServiceAccountName)
@@ -49,7 +49,7 @@ func TestDeleteJob(t *testing.T) {
4949
chart := NewChart()
5050
deleteTime := metav1.NewTime(time.Time{})
5151
chart.DeletionTimestamp = &deleteTime
52-
job, _, _ := job(chart)
52+
job, _, _ := job(chart, "6443")
5353
assert.Equal("helm-delete-traefik", job.Name)
5454
}
5555

pkg/controllers/controllers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func Register(ctx context.Context, systemNamespace, controllerName string, cfg c
7575
chart.Register(ctx,
7676
systemNamespace,
7777
controllerName,
78+
"6443",
7879
appCtx.K8s,
7980
appCtx.Apply,
8081
recorder,

0 commit comments

Comments
 (0)