Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Restore KubernetesConfig sans struct embedding (#2108)
Browse files Browse the repository at this point in the history
* restore properties to KubernetesConfig

* lint

* comment

* rebase errata
  • Loading branch information
jackfrancis authored Jan 19, 2018
1 parent 88bbc89 commit c488652
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 60 deletions.
74 changes: 44 additions & 30 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func (a *KubernetesAddon) IsEnabled(ifNil bool) bool {
}

// CloudProviderConfig contains the KubernetesConfig properties specific to the Cloud Provider
// TODO use this when strict JSON checking accommodates struct embedding
type CloudProviderConfig struct {
CloudProviderBackoff bool `json:"cloudProviderBackoff,omitempty"`
CloudProviderBackoffRetries int `json:"cloudProviderBackoffRetries,omitempty"`
Expand All @@ -208,6 +209,7 @@ type CloudProviderConfig struct {
}

// KubernetesConfigDeprecated are properties that are no longer operable and will be ignored
// TODO use this when strict JSON checking accommodates struct embedding
type KubernetesConfigDeprecated struct {
NonMasqueradeCidr string `json:"nonMasqueradeCidr,omitempty"`
NodeStatusUpdateFrequency string `json:"nodeStatusUpdateFrequency,omitempty"`
Expand All @@ -220,36 +222,48 @@ type KubernetesConfigDeprecated struct {
// KubernetesConfig contains the Kubernetes config structure, containing
// Kubernetes specific configuration
type KubernetesConfig struct {
KubernetesImageBase string `json:"kubernetesImageBase,omitempty"`
ClusterSubnet string `json:"clusterSubnet,omitempty"`
NetworkPolicy string `json:"networkPolicy,omitempty"`
ContainerRuntime string `json:"containerRuntime,omitempty"`
MaxPods int `json:"maxPods,omitempty"`
DockerBridgeSubnet string `json:"dockerBridgeSubnet,omitempty"`
DNSServiceIP string `json:"dnsServiceIP,omitempty"`
ServiceCIDR string `json:"serviceCidr,omitempty"`
CloudProviderConfig
UseManagedIdentity bool `json:"useManagedIdentity,omitempty"`
CustomHyperkubeImage string `json:"customHyperkubeImage,omitempty"`
DockerEngineVersion string `json:"dockerEngineVersion,omitempty"`
CustomCcmImage string `json:"customCcmImage,omitempty"` // Image for cloud-controller-manager
UseCloudControllerManager *bool `json:"useCloudControllerManager,omitempty"`
UseInstanceMetadata *bool `json:"useInstanceMetadata,omitempty"`
EnableRbac *bool `json:"enableRbac,omitempty"`
EnableSecureKubelet *bool `json:"enableSecureKubelet,omitempty"`
EnableAggregatedAPIs bool `json:"enableAggregatedAPIs,omitempty"`
GCHighThreshold int `json:"gchighthreshold,omitempty"`
GCLowThreshold int `json:"gclowthreshold,omitempty"`
EtcdVersion string `json:"etcdVersion,omitempty"`
EtcdDiskSizeGB string `json:"etcdDiskSizeGB,omitempty"`
EnableDataEncryptionAtRest *bool `json:"enableDataEncryptionAtRest,omitempty"`
EnablePodSecurityPolicy *bool `json:"enablePodSecurityPolicy,omitempty"`
Addons []KubernetesAddon `json:"addons,omitempty"`
KubeletConfig map[string]string `json:"kubeletConfig,omitempty"`
ControllerManagerConfig map[string]string `json:"controllerManagerConfig,omitempty"`
CloudControllerManagerConfig map[string]string `json:"cloudControllerManagerConfig,omitempty"`
APIServerConfig map[string]string `json:"apiServerConfig,omitempty"`
KubernetesConfigDeprecated
KubernetesImageBase string `json:"kubernetesImageBase,omitempty"`
ClusterSubnet string `json:"clusterSubnet,omitempty"`
NetworkPolicy string `json:"networkPolicy,omitempty"`
ContainerRuntime string `json:"containerRuntime,omitempty"`
MaxPods int `json:"maxPods,omitempty"`
DockerBridgeSubnet string `json:"dockerBridgeSubnet,omitempty"`
DNSServiceIP string `json:"dnsServiceIP,omitempty"`
ServiceCIDR string `json:"serviceCidr,omitempty"`
UseManagedIdentity bool `json:"useManagedIdentity,omitempty"`
CustomHyperkubeImage string `json:"customHyperkubeImage,omitempty"`
DockerEngineVersion string `json:"dockerEngineVersion,omitempty"`
CustomCcmImage string `json:"customCcmImage,omitempty"` // Image for cloud-controller-manager
UseCloudControllerManager *bool `json:"useCloudControllerManager,omitempty"`
UseInstanceMetadata *bool `json:"useInstanceMetadata,omitempty"`
EnableRbac *bool `json:"enableRbac,omitempty"`
EnableSecureKubelet *bool `json:"enableSecureKubelet,omitempty"`
EnableAggregatedAPIs bool `json:"enableAggregatedAPIs,omitempty"`
GCHighThreshold int `json:"gchighthreshold,omitempty"`
GCLowThreshold int `json:"gclowthreshold,omitempty"`
EtcdVersion string `json:"etcdVersion,omitempty"`
EtcdDiskSizeGB string `json:"etcdDiskSizeGB,omitempty"`
EnableDataEncryptionAtRest *bool `json:"enableDataEncryptionAtRest,omitempty"`
EnablePodSecurityPolicy *bool `json:"enablePodSecurityPolicy,omitempty"`
Addons []KubernetesAddon `json:"addons,omitempty"`
KubeletConfig map[string]string `json:"kubeletConfig,omitempty"`
ControllerManagerConfig map[string]string `json:"controllerManagerConfig,omitempty"`
CloudControllerManagerConfig map[string]string `json:"cloudControllerManagerConfig,omitempty"`
APIServerConfig map[string]string `json:"apiServerConfig,omitempty"`
CloudProviderBackoff bool `json:"cloudProviderBackoff,omitempty"`
CloudProviderBackoffRetries int `json:"cloudProviderBackoffRetries,omitempty"`
CloudProviderBackoffJitter float64 `json:"cloudProviderBackoffJitter,omitempty"`
CloudProviderBackoffDuration int `json:"cloudProviderBackoffDuration,omitempty"`
CloudProviderBackoffExponent float64 `json:"cloudProviderBackoffExponent,omitempty"`
CloudProviderRateLimit bool `json:"cloudProviderRateLimit,omitempty"`
CloudProviderRateLimitQPS float64 `json:"cloudProviderRateLimitQPS,omitempty"`
CloudProviderRateLimitBucket int `json:"cloudProviderRateLimitBucket,omitempty"`
NonMasqueradeCidr string `json:"nonMasqueradeCidr,omitempty"`
NodeStatusUpdateFrequency string `json:"nodeStatusUpdateFrequency,omitempty"`
HardEvictionThreshold string `json:"hardEvictionThreshold,omitempty"`
CtrlMgrNodeMonitorGracePeriod string `json:"ctrlMgrNodeMonitorGracePeriod,omitempty"`
CtrlMgrPodEvictionTimeout string `json:"ctrlMgrPodEvictionTimeout,omitempty"`
CtrlMgrRouteReconciliationPeriod string `json:"ctrlMgrRouteReconciliationPeriod,omitempty"`
}

// DcosConfig Configuration for DC/OS
Expand Down
26 changes: 17 additions & 9 deletions pkg/api/vlabs/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ func (a *KubernetesAddon) IsEnabled(ifNil bool) bool {
}

// CloudProviderConfig contains the KubernetesConfig parameters specific to the Cloud Provider
// TODO use this when strict JSON checking accommodates struct embedding
type CloudProviderConfig struct {
CloudProviderBackoff bool `json:"cloudProviderBackoff,omitempty"`
CloudProviderBackoffRetries int `json:"cloudProviderBackoffRetries,omitempty"`
Expand All @@ -228,15 +229,14 @@ type CloudProviderConfig struct {
// KubernetesConfig contains the Kubernetes config structure, containing
// Kubernetes specific configuration
type KubernetesConfig struct {
KubernetesImageBase string `json:"kubernetesImageBase,omitempty"`
ClusterSubnet string `json:"clusterSubnet,omitempty"`
DNSServiceIP string `json:"dnsServiceIP,omitempty"`
ServiceCidr string `json:"serviceCidr,omitempty"`
NetworkPolicy string `json:"networkPolicy,omitempty"`
ContainerRuntime string `json:"containerRuntime,omitempty"`
MaxPods int `json:"maxPods,omitempty"`
DockerBridgeSubnet string `json:"dockerBridgeSubnet,omitempty"`
CloudProviderConfig
KubernetesImageBase string `json:"kubernetesImageBase,omitempty"`
ClusterSubnet string `json:"clusterSubnet,omitempty"`
DNSServiceIP string `json:"dnsServiceIP,omitempty"`
ServiceCidr string `json:"serviceCidr,omitempty"`
NetworkPolicy string `json:"networkPolicy,omitempty"`
ContainerRuntime string `json:"containerRuntime,omitempty"`
MaxPods int `json:"maxPods,omitempty"`
DockerBridgeSubnet string `json:"dockerBridgeSubnet,omitempty"`
UseManagedIdentity bool `json:"useManagedIdentity,omitempty"`
CustomHyperkubeImage string `json:"customHyperkubeImage,omitempty"`
DockerEngineVersion string `json:"dockerEngineVersion,omitempty"`
Expand All @@ -257,6 +257,14 @@ type KubernetesConfig struct {
ControllerManagerConfig map[string]string `json:"controllerManagerConfig,omitempty"`
CloudControllerManagerConfig map[string]string `json:"cloudControllerManagerConfig,omitempty"`
APIServerConfig map[string]string `json:"apiServerConfig,omitempty"`
CloudProviderBackoff bool `json:"cloudProviderBackoff,omitempty"`
CloudProviderBackoffRetries int `json:"cloudProviderBackoffRetries,omitempty"`
CloudProviderBackoffJitter float64 `json:"cloudProviderBackoffJitter,omitempty"`
CloudProviderBackoffDuration int `json:"cloudProviderBackoffDuration,omitempty"`
CloudProviderBackoffExponent float64 `json:"cloudProviderBackoffExponent,omitempty"`
CloudProviderRateLimit bool `json:"cloudProviderRateLimit,omitempty"`
CloudProviderRateLimitQPS float64 `json:"cloudProviderRateLimitQPS,omitempty"`
CloudProviderRateLimitBucket int `json:"cloudProviderRateLimitBucket,omitempty"`
}

// DcosConfig Configuration for DC/OS
Expand Down
36 changes: 15 additions & 21 deletions pkg/api/vlabs/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,17 @@ func Test_KubernetesConfig_Validate(t *testing.T) {
}

c = KubernetesConfig{
ClusterSubnet: "10.120.0.0/16",
DockerBridgeSubnet: "10.120.1.0/16",
MaxPods: 42,
CloudProviderConfig: CloudProviderConfig{
CloudProviderBackoff: ValidKubernetesCloudProviderBackoff,
CloudProviderBackoffRetries: ValidKubernetesCloudProviderBackoffRetries,
CloudProviderBackoffJitter: ValidKubernetesCloudProviderBackoffJitter,
CloudProviderBackoffDuration: ValidKubernetesCloudProviderBackoffDuration,
CloudProviderBackoffExponent: ValidKubernetesCloudProviderBackoffExponent,
CloudProviderRateLimit: ValidKubernetesCloudProviderRateLimit,
CloudProviderRateLimitQPS: ValidKubernetesCloudProviderRateLimitQPS,
CloudProviderRateLimitBucket: ValidKubernetesCloudProviderRateLimitBucket,
},
ClusterSubnet: "10.120.0.0/16",
DockerBridgeSubnet: "10.120.1.0/16",
MaxPods: 42,
CloudProviderBackoff: ValidKubernetesCloudProviderBackoff,
CloudProviderBackoffRetries: ValidKubernetesCloudProviderBackoffRetries,
CloudProviderBackoffJitter: ValidKubernetesCloudProviderBackoffJitter,
CloudProviderBackoffDuration: ValidKubernetesCloudProviderBackoffDuration,
CloudProviderBackoffExponent: ValidKubernetesCloudProviderBackoffExponent,
CloudProviderRateLimit: ValidKubernetesCloudProviderRateLimit,
CloudProviderRateLimitQPS: ValidKubernetesCloudProviderRateLimitQPS,
CloudProviderRateLimitBucket: ValidKubernetesCloudProviderRateLimitBucket,
KubeletConfig: map[string]string{
"--node-status-update-frequency": ValidKubernetesNodeStatusUpdateFrequency,
},
Expand Down Expand Up @@ -253,10 +251,8 @@ func Test_KubernetesConfig_Validate(t *testing.T) {
// Tests that apply to pre-1.6 releases
for _, k8sVersion := range []string{common.KubernetesVersion1Dot5Dot8} {
c := KubernetesConfig{
CloudProviderConfig: CloudProviderConfig{
CloudProviderBackoff: true,
CloudProviderRateLimit: true,
},
CloudProviderBackoff: true,
CloudProviderRateLimit: true,
}
if err := c.Validate(k8sVersion); err == nil {
t.Error("should error because backoff and rate limiting are not available before v1.6.6")
Expand All @@ -269,10 +265,8 @@ func Test_KubernetesConfig_Validate(t *testing.T) {
common.KubernetesVersion1Dot8Dot1, common.KubernetesVersion1Dot8Dot2, common.KubernetesVersion1Dot8Dot4, common.KubernetesVersion1Dot8Dot6, common.KubernetesVersion1Dot8Dot7,
common.KubernetesVersion1Dot9Dot0, common.KubernetesVersion1Dot9Dot1, common.KubernetesVersion1Dot9Dot2} {
c := KubernetesConfig{
CloudProviderConfig: CloudProviderConfig{
CloudProviderBackoff: true,
CloudProviderRateLimit: true,
},
CloudProviderBackoff: true,
CloudProviderRateLimit: true,
}
if err := c.Validate(k8sVersion); err != nil {
t.Error("should not error when basic backoff and rate limiting are set to true with no options")
Expand Down

0 comments on commit c488652

Please sign in to comment.