Skip to content

Commit 104ee74

Browse files
committed
Fix disabling StorageClass management
Previously this was done in the manifests leading to empty files. kubectl doesn't like this, so protokube will always fail updating the addon when StorageClass management is disabled
1 parent 4366748 commit 104ee74

File tree

3 files changed

+27
-28
lines changed

3 files changed

+27
-28
lines changed

Diff for: upup/models/cloudup/resources/addons/storage-aws.addons.k8s.io/v1.15.0.yaml.template

-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{{ if WithDefaultBool .CloudConfig.ManageStorageClasses true }}
21
apiVersion: storage.k8s.io/v1
32
kind: StorageClass
43
metadata:
@@ -98,5 +97,3 @@ subjects:
9897
- kind: ServiceAccount
9998
name: aws-cloud-provider
10099
namespace: kube-system
101-
102-
{{ end }}

Diff for: upup/models/cloudup/resources/addons/storage-gce.addons.k8s.io/v1.7.0.yaml.template

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{{ if WithDefaultBool .CloudConfig.ManageStorageClasses true }}
21
apiVersion: storage.k8s.io/v1
32
kind: StorageClass
43
metadata:
@@ -13,5 +12,4 @@ metadata:
1312
addonmanager.kubernetes.io/mode: EnsureExists
1413
provisioner: kubernetes.io/gce-pd
1514
parameters:
16-
type: pd-standard
17-
{{ end }}
15+
type: pd-standard

Diff for: upup/pkg/fi/cloudup/bootstrapchannelbuilder/bootstrapchannelbuilder.go

+26-22
Original file line numberDiff line numberDiff line change
@@ -722,20 +722,23 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.ModelBuilderContext) (*Addon
722722
}
723723
}
724724

725-
if b.Cluster.Spec.GetCloudProvider() == kops.CloudProviderAWS {
726-
key := "storage-aws.addons.k8s.io"
725+
if fi.BoolValue(b.Cluster.Spec.CloudConfig.ManageStorageClasses) {
726+
if b.Cluster.Spec.GetCloudProvider() == kops.CloudProviderAWS {
727+
key := "storage-aws.addons.k8s.io"
727728

728-
{
729-
id := "v1.15.0"
730-
location := key + "/" + id + ".yaml"
729+
{
730+
id := "v1.15.0"
731+
location := key + "/" + id + ".yaml"
731732

732-
addons.Add(&channelsapi.AddonSpec{
733-
Name: fi.String(key),
734-
Selector: map[string]string{"k8s-addon": key},
735-
Manifest: fi.String(location),
736-
Id: id,
737-
})
733+
addons.Add(&channelsapi.AddonSpec{
734+
Name: fi.String(key),
735+
Selector: map[string]string{"k8s-addon": key},
736+
Manifest: fi.String(location),
737+
Id: id,
738+
})
739+
}
738740
}
741+
739742
}
740743

741744
if b.Cluster.Spec.GetCloudProvider() == kops.CloudProviderDO {
@@ -796,20 +799,21 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.ModelBuilderContext) (*Addon
796799
}
797800

798801
if b.Cluster.Spec.GetCloudProvider() == kops.CloudProviderGCE {
799-
key := "storage-gce.addons.k8s.io"
802+
if fi.BoolValue(b.Cluster.Spec.CloudConfig.ManageStorageClasses) {
803+
key := "storage-gce.addons.k8s.io"
800804

801-
{
802-
id := "v1.7.0"
803-
location := key + "/" + id + ".yaml"
805+
{
806+
id := "v1.7.0"
807+
location := key + "/" + id + ".yaml"
804808

805-
addons.Add(&channelsapi.AddonSpec{
806-
Name: fi.String(key),
807-
Selector: map[string]string{"k8s-addon": key},
808-
Manifest: fi.String(location),
809-
Id: id,
810-
})
809+
addons.Add(&channelsapi.AddonSpec{
810+
Name: fi.String(key),
811+
Selector: map[string]string{"k8s-addon": key},
812+
Manifest: fi.String(location),
813+
Id: id,
814+
})
815+
}
811816
}
812-
813817
if b.Cluster.Spec.CloudConfig != nil && b.Cluster.Spec.CloudConfig.GCPPDCSIDriver != nil && fi.BoolValue(b.Cluster.Spec.CloudConfig.GCPPDCSIDriver.Enabled) {
814818
key := "gcp-pd-csi-driver.addons.k8s.io"
815819
{

0 commit comments

Comments
 (0)