Skip to content

Commit

Permalink
Merge pull request #15601 from anthonyhaussman/feat/kops/karpenter_va…
Browse files Browse the repository at this point in the history
…riable

feat(karpenter): Variabilize image, logFormat and logLevel
  • Loading branch information
k8s-ci-robot committed Jul 17, 2023
2 parents 76eda9b + 4a01fc3 commit 3e51f74
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 6 deletions.
6 changes: 6 additions & 0 deletions k8s/crds/kops.k8s.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,12 @@ spec:
properties:
enabled:
type: boolean
image:
type: string
logEncoding:
type: string
logLevel:
type: string
type: object
keyStore:
description: KeyStore is the VFS path to where SSL keys and certificates
Expand Down
5 changes: 4 additions & 1 deletion pkg/apis/kops/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,10 @@ type ScalewaySpec struct {
}

type KarpenterConfig struct {
Enabled bool `json:"enabled,omitempty"`
Enabled bool `json:"enabled,omitempty"`
LogEncoding string `json:"logFormat,omitempty"`
LogLevel string `json:"logLevel,omitempty"`
Image string `json:"image,omitempty"`
}

// ServiceAccountIssuerDiscoveryConfig configures an OIDC Issuer.
Expand Down
5 changes: 4 additions & 1 deletion pkg/apis/kops/v1alpha2/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ type PodIdentityWebhookSpec struct {
}

type KarpenterConfig struct {
Enabled bool `json:"enabled,omitempty"`
Enabled bool `json:"enabled,omitempty"`
LogEncoding string `json:"logEncoding,omitempty"`
LogLevel string `json:"logLevel,omitempty"`
Image string `json:"image,omitempty"`
}

// ServiceAccountIssuerDiscoveryConfig configures an OIDC Issuer.
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pkg/apis/kops/v1alpha3/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,10 @@ type ScalewaySpec struct {
}

type KarpenterConfig struct {
Enabled bool `json:"enabled,omitempty"`
Enabled bool `json:"enabled,omitempty"`
LogEncoding string `json:"logEncoding,omitempty"`
LogLevel string `json:"logLevel,omitempty"`
Image string `json:"image,omitempty"`
}

// ServiceAccountIssuerDiscoveryConfig configures an OIDC Issuer.
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/kops/v1alpha3/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions pkg/model/components/karpenter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package components

import (
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/upup/pkg/fi/loader"
)

// KarpenterOptionsBuilder adds options for the cilium to the model
type KarpenterOptionsBuilder struct {
Context *OptionsContext
}

var _ loader.OptionsBuilder = &KarpenterOptionsBuilder{}

func (b *KarpenterOptionsBuilder) BuildOptions(o interface{}) error {
clusterSpec := o.(*kops.ClusterSpec)
c := clusterSpec.Karpenter
if c == nil {
return nil
}

if c.Image == "" {
c.Image = "public.ecr.aws/karpenter/controller:v0.28.1"
}

if c.LogEncoding == "" {
c.LogEncoding = "console"
}

if c.LogLevel == "" {
c.LogLevel = "debug"
}

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ spec:
useServiceAccountExternalPermissions: true
karpenter:
enabled: true
image: public.ecr.aws/karpenter/controller:v0.28.1
logEncoding: console
logLevel: debug
keyStore: memfs://clusters.example.com/minimal.example.com/pki
kubeAPIServer:
allowPrivileged: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ data:
# https://github.com/uber-go/zap/blob/aa3e73ec0896f8b066ddf668597a02f89628ee50/config.go
zap-logger-config: |
{
"level": "debug",
"level": "{{ .Karpenter.LogLevel }}",
"development": false,
"disableStacktrace": true,
"disableCaller": true,
Expand All @@ -1129,7 +1129,7 @@ data:
},
"outputPaths": ["stdout"],
"errorOutputPaths": ["stderr"],
"encoding": "console",
"encoding": "{{ .Karpenter.LogEncoding }}",
"encoderConfig": {
"timeKey": "time",
"levelKey": "level",
Expand Down Expand Up @@ -1482,7 +1482,7 @@ spec:
dnsPolicy: ClusterFirst
containers:
- name: controller
image: public.ecr.aws/karpenter/controller:v0.28.1
image: {{ .Karpenter.Image }}
imagePullPolicy: IfNotPresent
env:
- name: KUBERNETES_MIN_VERSION
Expand Down
1 change: 1 addition & 0 deletions upup/pkg/fi/cloudup/populate_cluster_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ func (c *populateClusterSpec) run(ctx context.Context, clientset simple.Clientse
codeModels = append(codeModels, &components.GCPCloudControllerManagerOptionsBuilder{OptionsContext: optionsContext})
codeModels = append(codeModels, &components.GCPPDCSIDriverOptionsBuilder{OptionsContext: optionsContext})
codeModels = append(codeModels, &components.HetznerCloudControllerManagerOptionsBuilder{OptionsContext: optionsContext})
codeModels = append(codeModels, &components.KarpenterOptionsBuilder{Context: optionsContext})
}
}

Expand Down

0 comments on commit 3e51f74

Please sign in to comment.