Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize api server port #198

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions pkg/controllers/chart/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ type Controller struct {
jobCache batchcontroller.JobCache
apply apply.Apply
recorder record.EventRecorder
apiServerPort string
}

func Register(ctx context.Context,
systemNamespace, managedBy string,
systemNamespace, managedBy, apiServerPort string,
k8s kubernetes.Interface,
apply apply.Apply,
recorder record.EventRecorder,
Expand All @@ -96,6 +97,7 @@ func Register(ctx context.Context,
jobs: jobs,
jobCache: jobCache,
recorder: recorder,
apiServerPort: apiServerPort,
}

c.apply = apply.
Expand Down Expand Up @@ -309,7 +311,7 @@ func (c *Controller) getJobAndRelatedResources(chart *v1.HelmChart) (*batch.Job,
}

// get the default job and configmaps
job, valuesSecret, contentConfigMap := job(chart)
job, valuesSecret, contentConfigMap := job(chart, c.apiServerPort)

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

func job(chart *v1.HelmChart) (*batch.Job, *corev1.Secret, *corev1.ConfigMap) {
func job(chart *v1.HelmChart, apiServerPort string) (*batch.Job, *corev1.Secret, *corev1.ConfigMap) {
jobImage := strings.TrimSpace(chart.Spec.JobImage)
if jobImage == "" {
jobImage = DefaultJobImage
Expand Down Expand Up @@ -481,7 +483,7 @@ func job(chart *v1.HelmChart) (*batch.Job, *corev1.Secret, *corev1.ConfigMap) {
Value: "127.0.0.1"},
{
Name: "KUBERNETES_SERVICE_PORT",
Value: "6443"},
Value: apiServerPort},
{
Name: "BOOTSTRAP",
Value: "true"},
Expand Down
4 changes: 2 additions & 2 deletions pkg/controllers/chart/chart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestSetVals(t *testing.T) {
func TestInstallJob(t *testing.T) {
assert := assert.New(t)
chart := NewChart()
job, _, _ := job(chart)
job, _, _ := job(chart, "6443")
assert.Equal("helm-install-traefik", job.Name)
assert.Equal(DefaultJobImage, job.Spec.Template.Spec.Containers[0].Image)
assert.Equal("helm-traefik", job.Spec.Template.Spec.ServiceAccountName)
Expand All @@ -49,7 +49,7 @@ func TestDeleteJob(t *testing.T) {
chart := NewChart()
deleteTime := metav1.NewTime(time.Time{})
chart.DeletionTimestamp = &deleteTime
job, _, _ := job(chart)
job, _, _ := job(chart, "6443")
assert.Equal("helm-delete-traefik", job.Name)
}

Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func Register(ctx context.Context, systemNamespace, controllerName string, cfg c
chart.Register(ctx,
systemNamespace,
controllerName,
"6443",
appCtx.K8s,
appCtx.Apply,
recorder,
Expand Down