@@ -12,6 +12,7 @@ import (
12
12
"time"
13
13
14
14
"github.com/invopop/jsonschema"
15
+ yamlv3 "gopkg.in/yaml.v3"
15
16
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
16
17
"k8s.io/apimachinery/pkg/labels"
17
18
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -173,6 +174,10 @@ type Standalone struct {
173
174
// Enabled defines if standalone mode should be enabled.
174
175
Enabled bool `json:"enabled,omitempty"`
175
176
177
+ // SyncConfig allows controlling the vCluster config through a secret "vcluster-config" in the namespace "kube-system". vCluster will watch for changes in this secret and
178
+ // update the local config accordingly and restart vCluster if needed.
179
+ SyncConfig StandaloneSyncConfig `json:"syncConfig,omitempty"`
180
+
176
181
// DataDir defines the data directory for the standalone mode.
177
182
DataDir string `json:"dataDir,omitempty"`
178
183
@@ -186,13 +191,15 @@ type Standalone struct {
186
191
JoinNode StandaloneJoinNode `json:"joinNode,omitempty"`
187
192
}
188
193
194
+ type StandaloneSyncConfig struct {
195
+ // Enabled defines if config syncing should be enabled.
196
+ Enabled bool `json:"enabled,omitempty"`
197
+ }
198
+
189
199
type StandaloneJoinNode struct {
190
200
// Enabled defines if the standalone node should be joined into the cluster. If false, only the control plane binaries will be executed and no node will show up in the actual cluster.
191
201
Enabled bool `json:"enabled,omitempty"`
192
202
193
- // Name defines the name of the standalone node. If empty the node will get the hostname as name.
194
- Name string `json:"name,omitempty"`
195
-
196
203
JoinConfiguration `json:",inline"`
197
204
}
198
205
@@ -376,8 +383,9 @@ type AutoUpgrade struct {
376
383
}
377
384
378
385
type Kubelet struct {
379
- // CgroupDriver defines the cgroup driver to use for the kubelet.
380
- CgroupDriver string `json:"cgroupDriver,omitempty"`
386
+ // Config is the config for the kubelet that will be merged into the default kubelet config. More information can be found here:
387
+ // https://kubernetes.io/docs/reference/config-api/kubelet-config.v1beta1/#kubelet-config-k8s-io-v1beta1-KubeletConfiguration
388
+ Config map [string ]interface {} `json:"config,omitempty"`
381
389
}
382
390
383
391
type KubeProxy struct {
@@ -404,6 +412,10 @@ type KubeProxy struct {
404
412
405
413
// ExtraArgs are additional arguments to pass to the kube-proxy.
406
414
ExtraArgs []string `json:"extraArgs,omitempty"`
415
+
416
+ // Config is the config for the kube-proxy that will be merged into the default kube-proxy config. More information can be found here:
417
+ // https://kubernetes.io/docs/reference/config-api/kube-proxy-config.v1alpha1/#kubeproxy-config-k8s-io-v1alpha1-KubeProxyConfiguration
418
+ Config map [string ]interface {} `json:"config,omitempty"`
407
419
}
408
420
409
421
type Konnectivity struct {
@@ -534,11 +546,17 @@ type ExternalSecrets struct {
534
546
}
535
547
536
548
type ExternalSecretsSync struct {
549
+ // ToHost defines what resources are synced from the virtual cluster to the host
550
+ ToHost ExternalSecretsSyncToHostConfig `json:"toHost,omitempty"`
551
+ // FromHost defines what resources are synced from the host cluster to the virtual cluster
552
+ FromHost ExternalSecretsSyncFromHostConfig `json:"fromHost,omitempty"`
537
553
// ExternalSecrets defines if external secrets should get synced from the virtual cluster to the host cluster.
538
554
ExternalSecrets EnableSwitch `json:"externalSecrets,omitempty"`
539
555
// Stores defines if secret stores should get synced from the virtual cluster to the host cluster and then bi-directionally.
556
+ // Deprecated: Use Integrations.ExternalSecrets.Sync.ToHost.Stores instead.
540
557
Stores EnableSwitch `json:"stores,omitempty"`
541
558
// ClusterStores defines if cluster secrets stores should get synced from the host cluster to the virtual cluster.
559
+ // Deprecated: Use Integrations.ExternalSecrets.Sync.FromHost.ClusterStores instead.
542
560
ClusterStores ClusterStoresSyncConfig `json:"clusterStores,omitempty"`
543
561
}
544
562
@@ -548,6 +566,27 @@ type ClusterStoresSyncConfig struct {
548
566
Selector LabelSelector `json:"selector,omitempty"`
549
567
}
550
568
569
+ type ExternalSecretsSyncToHostConfig struct {
570
+ // ExternalSecrets allows to configure if only a subset of ExternalSecrets matching a label selector should get synced from the virtual cluster to the host cluster.
571
+ ExternalSecrets SelectorConfig `json:"externalSecrets,omitempty"`
572
+ // Stores defines if secret stores should get synced from the virtual cluster to the host cluster and then bi-directionally.
573
+ Stores EnableSwitchSelector `json:"stores,omitempty"`
574
+ }
575
+
576
+ type ExternalSecretsSyncFromHostConfig struct {
577
+ // ClusterStores defines if cluster secrets stores should get synced from the host cluster to the virtual cluster.
578
+ ClusterStores EnableSwitchSelector `json:"clusterStores,omitempty"`
579
+ }
580
+
581
+ type SelectorConfig struct {
582
+ Selector StandardLabelSelector `json:"selector,omitempty"`
583
+ }
584
+
585
+ type EnableSwitchSelector struct {
586
+ SelectorConfig
587
+ EnableSwitch
588
+ }
589
+
551
590
type LabelSelector struct {
552
591
// Labels defines what labels should be looked for
553
592
Labels map [string ]string `json:"labels,omitempty"`
@@ -835,6 +874,10 @@ func (c *Config) IsProFeatureEnabled() bool {
835
874
return true
836
875
}
837
876
877
+ if c .PrivateNodes .Enabled {
878
+ return true
879
+ }
880
+
838
881
return false
839
882
}
840
883
@@ -1278,7 +1321,7 @@ type SyncRewriteHosts struct {
1278
1321
1279
1322
type SyncRewriteHostsInitContainer struct {
1280
1323
// Image is the image virtual cluster should use to rewrite this FQDN.
1281
- Image string `json:"image,omitempty"`
1324
+ Image Image `json:"image,omitempty"`
1282
1325
1283
1326
// Resources are the resources that should be assigned to the init container for each stateful set init container.
1284
1327
Resources Resources `json:"resources,omitempty"`
@@ -1572,7 +1615,9 @@ type ControlPlaneStatefulSet struct {
1572
1615
Pods LabelsAndAnnotations `json:"pods,omitempty"`
1573
1616
1574
1617
// Image is the image for the controlPlane statefulSet container
1575
- Image StatefulSetImage `json:"image,omitempty"`
1618
+ // It defaults to the vCluster pro repository that includes the optional pro modules that are turned off by default.
1619
+ // If you still want to use the pure OSS build, set the repository to 'loft-sh/vcluster-oss'.
1620
+ Image Image `json:"image,omitempty"`
1576
1621
1577
1622
// ImagePullPolicy is the policy how to pull the image.
1578
1623
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
@@ -1629,7 +1674,7 @@ type DistroK8s struct {
1629
1674
// ControllerManager holds configuration specific to starting the controller manager.
1630
1675
ControllerManager DistroContainerEnabled `json:"controllerManager,omitempty"`
1631
1676
1632
- // Scheduler holds configuration specific to starting the scheduler. Enable this via controlPlane.advanced.virtualScheduler.enabled
1677
+ // Scheduler holds configuration specific to starting the scheduler.
1633
1678
Scheduler DistroContainerEnabled `json:"scheduler,omitempty"`
1634
1679
1635
1680
DistroCommon `json:",inline"`
@@ -1670,20 +1715,6 @@ type DistroContainerEnabled struct {
1670
1715
ExtraArgs []string `json:"extraArgs,omitempty"`
1671
1716
}
1672
1717
1673
- type StatefulSetImage struct {
1674
- // Configure the registry of the container image, e.g. my-registry.com or ghcr.io
1675
- // It defaults to ghcr.io and can be overriding either by using this field or controlPlane.advanced.defaultImageRegistry
1676
- Registry string `json:"registry,omitempty"`
1677
-
1678
- // Configure the repository of the container image, e.g. my-repo/my-image.
1679
- // It defaults to the vCluster pro repository that includes the optional pro modules that are turned off by default.
1680
- // If you still want to use the pure OSS build, use 'loft-sh/vcluster-oss' instead.
1681
- Repository string `json:"repository,omitempty"`
1682
-
1683
- // Tag is the tag of the container image, e.g. latest
1684
- Tag string `json:"tag,omitempty"`
1685
- }
1686
-
1687
1718
type Image struct {
1688
1719
// Registry is the registry of the container image, e.g. my-registry.com or ghcr.io. This setting can be globally
1689
1720
// overridden via the controlPlane.advanced.defaultImageRegistry option. Empty means docker hub.
@@ -1692,10 +1723,64 @@ type Image struct {
1692
1723
// Repository is the repository of the container image, e.g. my-repo/my-image
1693
1724
Repository string `json:"repository,omitempty"`
1694
1725
1695
- // Tag is the tag of the container image, e.g. latest. If set to the default, it will use the host Kubernetes version.
1726
+ // Tag is the tag of the container image, and is the default version.
1696
1727
Tag string `json:"tag,omitempty"`
1697
1728
}
1698
1729
1730
+ // UnmarshalJSON makes the schema change from string to Image backwards compatible
1731
+ func (i * Image ) UnmarshalJSON (data []byte ) error {
1732
+ var str string
1733
+ if err := json .Unmarshal (data , & str ); err == nil {
1734
+ ParseImageRef (str , i )
1735
+ return nil
1736
+ }
1737
+
1738
+ type Alias Image
1739
+ var aux Alias
1740
+ if err := json .Unmarshal (data , & aux ); err != nil {
1741
+ return err
1742
+ }
1743
+ * i = Image (aux )
1744
+ return nil
1745
+ }
1746
+
1747
+ // UnmarshalYAML makes the schema change from string to Image backwards compatible
1748
+ func (i * Image ) UnmarshalYAML (node * yamlv3.Node ) error {
1749
+ if node .Kind == yamlv3 .ScalarNode {
1750
+ ParseImageRef (node .Value , i )
1751
+ return nil
1752
+ }
1753
+
1754
+ type Alias Image
1755
+ var aux Alias
1756
+ if err := node .Decode (& aux ); err != nil {
1757
+ return err
1758
+ }
1759
+ * i = Image (aux )
1760
+ return nil
1761
+ }
1762
+
1763
+ func (i * Image ) String () (ref string ) {
1764
+ if i == nil {
1765
+ return
1766
+ }
1767
+
1768
+ if i .Registry != "" {
1769
+ ref = i .Registry + "/"
1770
+ }
1771
+
1772
+ if i .Registry != "" && i .Repository != "" && ! strings .ContainsRune (i .Repository , '/' ) {
1773
+ ref += "library/"
1774
+ }
1775
+ ref += i .Repository
1776
+
1777
+ if i .Tag != "" {
1778
+ ref += ":" + i .Tag
1779
+ }
1780
+
1781
+ return ref
1782
+ }
1783
+
1699
1784
type ImagePullSecretName struct {
1700
1785
// Name of the image pull secret to use.
1701
1786
Name string `json:"name,omitempty"`
0 commit comments