Karmadactl Configuration (v1alpha1)

Overview

The karmadactl init command supports loading configuration parameters from a YAML file to simplify the deployment process for Karmada’s control plane. This feature allows users to define all the necessary settings in a configuration file, reducing the complexity of managing numerous command-line flags and improving consistency across different environments.

This document explains the structure of the YAML configuration file used with karmadactl init --config, based on the v1alpha1 version of the configuration schema.

YAML Configuration Structure

The configuration file is structured into the following key sections:

apiVersion

Specifies the API version of the configuration file. For Karmada initialization, it should always be config.karmada.io/v1alpha1.

  1. apiVersion: config.karmada.io/v1alpha1

kind

Defines the type of configuration. For Karmada initialization, this value should always be InitConfiguration.

  1. kind: KarmadaInitConfig

spec

Contains the main configuration specifications for initializing Karmada.

certificates

Configures the certificate information required by Karmada components.

  • caCertFile: Path to the root CA certificate file. If not specified, a new self-signed CA certificate will be generated.
  • caKeyFile: Path to the root CA key file. If not specified, a new self-signed CA key will be generated.
  • externalDNS: A list of external DNS names to include in the certificates’ Subject Alternative Names (SANs).
  • externalIP: A list of external IP addresses to include in the certificates’ SANs.
  • validityPeriod: The validity period of the certificates, specified in Go duration format (e.g., "8760h0m0s" for one year).
  1. spec:
  2. certificates:
  3. caCertFile: "/etc/karmada/pki/ca.crt"
  4. caKeyFile: "/etc/karmada/pki/ca.key"
  5. externalDNS:
  6. - "localhost"
  7. - "example.com"
  8. externalIP:
  9. - "192.168.1.2"
  10. - "172.16.1.2"
  11. validityPeriod: "8760h0m0s"

etcd

Configures the Etcd cluster used by Karmada. You can choose between a local Etcd cluster (local) or an external Etcd cluster (external).

local

Defines settings for deploying a local Etcd cluster as part of the Karmada control plane.

  • repository: The Docker image repository for the Etcd image.
  • tag: The image tag (version) of Etcd.
  • dataPath: Filesystem path where Etcd will store its data on the host.
  • initImage: Image used for the Etcd init container, typically a lightweight image like Alpine Linux.
  • nodeSelectorLabels: Labels used to select the nodes where Etcd pods will be scheduled.
  • pvcSize: The size of the PersistentVolumeClaim used by Etcd when storageMode is set to PVC.
  • replicas: Number of Etcd replicas to deploy. For high availability, an odd number of replicas is recommended (e.g., 3, 5).
  • storageMode: Storage mode for Etcd data. Options are emptyDir, hostPath, or PVC.
  1. spec:
  2. etcd:
  3. local:
  4. repository: "registry.k8s.io/etcd"
  5. tag: "latest"
  6. dataPath: "/var/lib/karmada-etcd"
  7. initImage:
  8. repository: "alpine"
  9. tag: "3.19.1"
  10. nodeSelectorLabels:
  11. karmada.io/etcd: "true"
  12. pvcSize: "5Gi"
  13. replicas: 3
  14. storageMode: "PVC"
external

Configures connection settings for an external Etcd cluster.

  • endpoints: List of URLs to the external Etcd servers.
  • caFile: Path to the CA certificate file for the external Etcd cluster.
  • certFile: Path to the client certificate file for authentication.
  • keyFile: Path to the client key file for authentication.
  • keyPrefix: Key prefix used in the external Etcd cluster to segregate data.
  1. spec:
  2. etcd:
  3. external:
  4. endpoints:
  5. - "https://example.com:8443"
  6. caFile: "/path/to/your/ca.crt"
  7. certFile: "/path/to/your/cert.crt"
  8. keyFile: "/path/to/your/key.key"
  9. keyPrefix: "ext-"

hostCluster

Specifies information about the host Kubernetes cluster where Karmada will be installed.

  • apiEndpoint: The API server endpoint of the host cluster.
  • kubeconfig: Path to the kubeconfig file used to access the host cluster.
  • context: The context name within the kubeconfig file to use.
  • domain: The DNS domain of the host cluster (e.g., cluster.local).
  1. spec:
  2. hostCluster:
  3. apiEndpoint: "https://kubernetes.example.com"
  4. kubeconfig: "/root/.kube/config"
  5. context: "karmada-host"
  6. domain: "cluster.local"

images

Configures image-related settings for Karmada and Kubernetes components.

  • imagePullPolicy: The image pull policy. Options are Always, IfNotPresent, or Never.
  • imagePullSecrets: A list of Kubernetes secrets used to authenticate with private image registries.
  • kubeImageMirrorCountry: Country code for selecting a Kubernetes image mirror (e.g., cn for China).
  • kubeImageRegistry: Custom Docker registry to pull Kubernetes images from.
  • kubeImageTag: The tag (version) of the Kubernetes images to use.
  • privateRegistry:
    • registry: The address of a private image registry. If specified, all images will be pulled from this registry.
  1. spec:
  2. images:
  3. imagePullPolicy: "IfNotPresent"
  4. imagePullSecrets:
  5. - "PullSecret1"
  6. - "PullSecret2"
  7. kubeImageMirrorCountry: "cn"
  8. kubeImageRegistry: "registry.cn-hangzhou.aliyuncs.com/google_containers"
  9. kubeImageTag: "v1.29.6"
  10. privateRegistry:
  11. registry: "my.private.registry"

components

Defines configurations for individual Karmada components.

karmadaAPIServer
  • repository: Docker image repository for the Karmada API Server.
  • tag: Image tag for the Karmada API Server.
  • replicas: Number of replicas for the API Server deployment.
  • advertiseAddress: The IP address that the API Server will advertise to clients.
  • networking:
    • namespace: Kubernetes namespace where the API Server will be deployed.
    • port: The port number on which the API Server will listen.
  1. spec:
  2. components:
  3. karmadaAPIServer:
  4. repository: "karmada/kube-apiserver"
  5. tag: "v1.29.6"
  6. replicas: 1
  7. advertiseAddress: "192.168.1.100"
  8. networking:
  9. namespace: "karmada-system"
  10. port: 32443
karmadaAggregatedAPIServer
  • repository: Docker image repository for the Aggregated API Server.
  • tag: Image tag for the Aggregated API Server.
  • replicas: Number of replicas.
  1. spec:
  2. components:
  3. karmadaAggregatedAPIServer:
  4. repository: "karmada/karmada-aggregated-apiserver"
  5. tag: "v0.0.0-master"
  6. replicas: 1
kubeControllerManager
  • repository: Docker image repository for the Kube Controller Manager.
  • tag: Image tag for the Kube Controller Manager.
  • replicas: Number of replicas.
  1. spec:
  2. components:
  3. kubeControllerManager:
  4. repository: "karmada/kube-controller-manager"
  5. tag: "v1.29.6"
  6. replicas: 1
karmadaControllerManager
  • repository: Docker image repository for the Karmada Controller Manager.
  • tag: Image tag for the Karmada Controller Manager.
  • replicas: Number of replicas.
  1. spec:
  2. components:
  3. karmadaControllerManager:
  4. repository: "karmada/karmada-controller-manager"
  5. tag: "v0.0.0-master"
  6. replicas: 1
karmadaScheduler
  • repository: Docker image repository for the Karmada Scheduler.
  • tag: Image tag for the Karmada Scheduler.
  • replicas: Number of replicas.
  1. spec:
  2. components:
  3. karmadaScheduler:
  4. repository: "karmada/karmada-scheduler"
  5. tag: "v0.0.0-master"
  6. replicas: 1
karmadaWebhook
  • repository: Docker image repository for the Karmada Webhook.
  • tag: Image tag for the Karmada Webhook.
  • replicas: Number of replicas.
  1. spec:
  2. components:
  3. karmadaWebhook:
  4. repository: "karmada/karmada-webhook"
  5. tag: "v0.0.0-master"
  6. replicas: 1

karmadaDataPath

Specifies the directory on the host where Karmada stores its data, including kubeconfig files, certificates, and CRDs.

  1. spec:
  2. karmadaDataPath: "/etc/karmada"

karmadaPKIPath

Specifies the directory on the host where Karmada stores its PKI (Public Key Infrastructure) files, such as certificates and keys.

  1. spec:
  2. karmadaPKIPath: "/etc/karmada/pki"

karmadaCRDs

Specifies the URL or path to the tarball containing Karmada Custom Resource Definitions (CRDs) to be installed.

  1. spec:
  2. karmadaCRDs: "https://github.com/karmada-io/karmada/releases/download/test/crds.tar.gz"

waitComponentReadyTimeout

Specifies the timeout in seconds for waiting for Karmada components to become ready. A value of 0 means wait indefinitely.

  1. spec:
  2. waitComponentReadyTimeout: 120

Complete Example Configuration File

Below is a complete example of the structure of the karmada-init.yaml file,

  1. apiVersion: config.karmada.io/v1alpha1
  2. kind: KarmadaInitConfig
  3. spec:
  4. certificates:
  5. caCertFile: "/path/to/your/ca.crt"
  6. caKeyFile: "/path/to/your/ca.key"
  7. externalDNS:
  8. - "localhost"
  9. - "example.com"
  10. externalIP:
  11. - "192.168.1.2"
  12. - "172.16.1.2"
  13. validityPeriod: "8760h0m0s"
  14. etcd:
  15. local:
  16. repository: "registry.k8s.io/etcd"
  17. tag: "latest"
  18. dataPath: "/var/lib/karmada-etcd"
  19. initImage:
  20. repository: "alpine"
  21. tag: "3.19.1"
  22. nodeSelectorLabels:
  23. karmada.io/etcd: "true"
  24. pvcSize: "5Gi"
  25. replicas: 3
  26. storageMode: "PVC"
  27. # external:
  28. # endpoints:
  29. # - "https://example.com:8443"
  30. # caFile: "/path/to/your/ca.crt"
  31. # certFile: "/path/to/your/cert.crt"
  32. # keyFile: "/path/to/your/key.key"
  33. # keyPrefix: "ext-"
  34. hostCluster:
  35. apiEndpoint: "https://kubernetes.example.com"
  36. kubeconfig: "/root/.kube/config"
  37. context: "karmada-host"
  38. domain: "cluster.local"
  39. images:
  40. imagePullPolicy: "IfNotPresent"
  41. imagePullSecrets:
  42. - "PullSecret1"
  43. - "PullSecret2"
  44. kubeImageMirrorCountry: "cn"
  45. kubeImageRegistry: "registry.cn-hangzhou.aliyuncs.com/google_containers"
  46. kubeImageTag: "v1.29.6"
  47. privateRegistry:
  48. registry: "my.private.registry"
  49. components:
  50. karmadaAPIServer:
  51. repository: "registry.k8s.io/kube-apiserver"
  52. tag: "v1.30.0"
  53. replicas: 1
  54. advertiseAddress: "192.168.1.100"
  55. networking:
  56. namespace: "karmada-system"
  57. port: 32443
  58. karmadaAggregatedAPIServer:
  59. repository: "docker.io/karmada/karmada-aggregated-apiserver"
  60. tag: "v1.10.3"
  61. replica: 1
  62. kubeControllerManager:
  63. repository: "registry.k8s.io/kube-controller-manager"
  64. tag: "v1.30.0"
  65. replica: 1
  66. karmadaControllerManager:
  67. repository: "docker.io/karmada/karmada-controller-manager"
  68. tag: "v1.10.3"
  69. replica: 1
  70. karmadaScheduler:
  71. repository: "docker.io/karmada/karmada-scheduler"
  72. tag: "v1.10.3"
  73. replica: 1
  74. karmadaWebhook:
  75. repository: "docker.io/karmada/karmada-webhook"
  76. tag: "v1.10.3"
  77. replica: 1
  78. karmadaDataPath: "/etc/karmada"
  79. karmadaPKIPath: "/etc/karmada/pki"
  80. karmadaCRDs: "https://github.com/karmada-io/karmada/releases/download/test/crds.tar.gz"
  81. waitComponentReadyTimeout: 120

Using the Configuration File

To use this configuration file with karmadactl init, simply pass the path to the YAML file as an argument to the --config flag:

  1. karmadactl init --config /path/to/karmada-init.yaml

Overriding Configuration File Values

If necessary, command-line flags can still be used in conjunction with the configuration file. The parameters specified via the command line will override those in the configuration file. For example, to override the number of API server replicas, you could use:

  1. karmadactl init --config /path/to/karmada-init.yaml --karmada-apiserver-replicas 5