Skip to content

Commit 80325bf

Browse files
karpenter: clarify createServiceAccount semantics in docs, schema, and runtime log (#8720)
The karpenter.createServiceAccount flag controls which component creates the 'karpenter' service account (eksctl vs the Karpenter Helm chart), not whether a service account is created. A SA always ends up on the cluster either way. The previous docs ("create a service account or not") and silent log output for the true case made this confusing. This change: - Rewrites the CreateServiceAccount struct-field comment in pkg/apis/eksctl.io/v1alpha5/types.go to describe the actual behavior, and regenerates schema.json. - Adds a dedicated 'createServiceAccount' subsection to userdocs/src/usage/eksctl-karpenter.md explaining both modes. - Adds Info-level log output at runtime so eksctl reports which component will create the SA. No behavior changes.
1 parent 59d2475 commit 80325bf

4 files changed

Lines changed: 38 additions & 4 deletions

File tree

pkg/actions/karpenter/create.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ func (i *Installer) Create(ctx context.Context) error {
6060
}
6161
if api.IsEnabled(i.Config.Karpenter.CreateServiceAccount) {
6262
// Create the service account role only.
63+
// The Karpenter Helm chart will create the Kubernetes service
64+
// account (serviceAccount.create=true is passed to the chart in
65+
// pkg/karpenter/karpenter.go).
6366
iamServiceAccount.RoleOnly = api.Enabled()
67+
logger.Info("karpenter.createServiceAccount=true: eksctl will create only the IAM role; the Karpenter Helm chart will create the %q service account in namespace %q", karpenter.DefaultServiceAccountName, karpenter.DefaultNamespace)
68+
} else {
69+
logger.Info("karpenter.createServiceAccount=false: eksctl will create both the IAM role and the %q service account in namespace %q", karpenter.DefaultServiceAccountName, karpenter.DefaultNamespace)
6470
}
6571
karpenterServiceAccountTaskTree := i.StackManager.NewTasksToCreateIAMServiceAccounts([]*api.ClusterIAMServiceAccount{iamServiceAccount}, i.OIDC, clientSetGetter)
6672
logger.Info(karpenterServiceAccountTaskTree.Describe())

pkg/apis/eksctl.io/v1alpha5/assets/schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,8 +1549,8 @@
15491549
"properties": {
15501550
"createServiceAccount": {
15511551
"type": "boolean",
1552-
"description": "create a service account or not.",
1553-
"x-intellij-html-description": "create a service account or not."
1552+
"description": "controls which component creates the \"karpenter\" service account in the \"karpenter\" namespace. When true, eksctl creates only the IAM role via an iamserviceaccount CloudFormation stack and delegates service account creation to the Karpenter Helm chart (which is installed with serviceAccount.create=true). When false (the default), eksctl creates both the IAM role and the Kubernetes service account, and the Helm chart is installed with serviceAccount.create=false. Either way a \"karpenter\" service account exists on the cluster after installation; this flag does not prevent the service account from being created.",
1553+
"x-intellij-html-description": "controls which component creates the "karpenter" service account in the "karpenter" namespace. When true, eksctl creates only the IAM role via an iamserviceaccount CloudFormation stack and delegates service account creation to the Karpenter Helm chart (which is installed with serviceAccount.create=true). When false (the default), eksctl creates both the IAM role and the Kubernetes service account, and the Helm chart is installed with serviceAccount.create=false. Either way a "karpenter" service account exists on the cluster after installation; this flag does not prevent the service account from being created."
15541554
},
15551555
"defaultInstanceProfile": {
15561556
"type": "string",

pkg/apis/eksctl.io/v1alpha5/types.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,16 @@ type Karpenter struct {
11361136
// Version defines the Karpenter version to install
11371137
// +required
11381138
Version string `json:"version"`
1139-
// CreateServiceAccount create a service account or not.
1139+
// CreateServiceAccount controls which component creates the "karpenter"
1140+
// service account in the "karpenter" namespace. When true, eksctl creates
1141+
// only the IAM role via an iamserviceaccount CloudFormation stack and
1142+
// delegates service account creation to the Karpenter Helm chart (which
1143+
// is installed with serviceAccount.create=true). When false (the default),
1144+
// eksctl creates both the IAM role and the Kubernetes service account,
1145+
// and the Helm chart is installed with serviceAccount.create=false.
1146+
// Either way a "karpenter" service account exists on the cluster after
1147+
// installation; this flag does not prevent the service account from being
1148+
// created.
11401149
// +optional
11411150
CreateServiceAccount *bool `json:"createServiceAccount,omitempty"`
11421151
// DefaultInstanceProfile override the default IAM instance profile

userdocs/src/usage/eksctl-karpenter.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,30 @@ to be set:
3535
```yaml
3636
karpenter:
3737
version: '1.2.1'
38-
createServiceAccount: true # default is false
38+
createServiceAccount: true # default is false; see note below on its meaning
3939
defaultInstanceProfile: 'KarpenterNodeInstanceProfile' # default is to use the IAM instance profile created by eksctl
4040
withSpotInterruptionQueue: true # adds all required policies and rules for supporting Spot Interruption Queue, default is false
4141
```
4242
43+
### `createServiceAccount`
44+
45+
This flag controls *which component* creates the `karpenter` service account in
46+
the `karpenter` namespace. It does **not** prevent the service account from
47+
being created — a `karpenter` service account will always exist on the cluster
48+
after installation.
49+
50+
* `createServiceAccount: false` (default) — eksctl creates both the IAM role
51+
(via an `iamserviceaccount` CloudFormation stack) and the Kubernetes service
52+
account, and installs the Karpenter Helm chart with
53+
`serviceAccount.create=false` so the chart reuses the existing service
54+
account.
55+
* `createServiceAccount: true` — eksctl creates only the IAM role and installs
56+
the Helm chart with `serviceAccount.create=true`, letting the chart create
57+
the service account (annotated with the IAM role ARN for IRSA).
58+
59+
Either mode results in a working `karpenter` service account; the choice
60+
affects only which tool owns the Kubernetes object.
61+
4362
OIDC must be defined in order to install Karpenter.
4463

4564
Once Karpenter is successfully installed, add [NodePool(s)](https://karpenter.sh/docs/concepts/nodepools/) and [NodeClass(es)](https://karpenter.sh/docs/concepts/nodeclasses/) to allow Karpenter

0 commit comments

Comments
 (0)