-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scaleway: terraform support (#15892)
* tasks dependencies * FindAddresses should proceed even if LBID is empty * refacto instance: handle several instances in IG + volumeSize in model * refacto lb_backend: set servers' IPs in backend task rather than instance * dns changes for tf support * render Scaleway s3 objects + add zone to outputs * add terraform support to documentation * new instance unique name should be given according to actual instances names * avoid untimely changes in tf + tag instance IPs to avoid orphaned IPs at cluster deletion * update integration tests * review comments * add IPs to the resources to be deleted with the cluster * add task + model for DNS record
- Loading branch information
Showing
22 changed files
with
931 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
Copyright 2023 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package scalewaymodel | ||
|
||
import ( | ||
"strings" | ||
|
||
domain "github.com/scaleway/scaleway-sdk-go/api/domain/v2beta1" | ||
"k8s.io/kops/upup/pkg/fi" | ||
"k8s.io/kops/upup/pkg/fi/cloudup/scalewaytasks" | ||
) | ||
|
||
const ( | ||
placeholderIP = "203.0.113.123" | ||
kopsControllerInternalRecordPrefix = "kops-controller.internal." | ||
defaultTTL = uint32(60) | ||
) | ||
|
||
type DNSModelBuilder struct { | ||
*ScwModelContext | ||
Lifecycle fi.Lifecycle | ||
} | ||
|
||
var _ fi.CloudupModelBuilder = &DNSModelBuilder{} | ||
|
||
func (b *DNSModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { | ||
if !b.Cluster.PublishesDNSRecords() { | ||
return nil | ||
} | ||
|
||
if !b.UseLoadBalancerForAPI() { | ||
recordShortName := strings.TrimSuffix(b.Cluster.Spec.API.PublicName, "."+b.Cluster.Spec.DNSZone) | ||
dnsAPIExternal := &scalewaytasks.DNSRecord{ | ||
Name: fi.PtrTo(recordShortName), | ||
Data: fi.PtrTo(placeholderIP), | ||
DNSZone: fi.PtrTo(b.Cluster.Spec.DNSZone), | ||
Type: fi.PtrTo(domain.RecordTypeA.String()), | ||
TTL: fi.PtrTo(defaultTTL), | ||
Lifecycle: b.Lifecycle, | ||
} | ||
c.AddTask(dnsAPIExternal) | ||
} | ||
|
||
if !b.UseLoadBalancerForInternalAPI() { | ||
recordShortName := strings.TrimSuffix(b.Cluster.APIInternalName(), "."+b.Cluster.Spec.DNSZone) | ||
dnsAPIInternal := &scalewaytasks.DNSRecord{ | ||
Name: fi.PtrTo(recordShortName), | ||
Data: fi.PtrTo(placeholderIP), | ||
DNSZone: fi.PtrTo(b.Cluster.Spec.DNSZone), | ||
Type: fi.PtrTo(domain.RecordTypeA.String()), | ||
TTL: fi.PtrTo(defaultTTL), | ||
Lifecycle: b.Lifecycle, | ||
} | ||
c.AddTask(dnsAPIInternal) | ||
} | ||
|
||
recordSuffix := strings.TrimSuffix(b.Cluster.ObjectMeta.Name, "."+b.Cluster.Spec.DNSZone) | ||
recordShortName := kopsControllerInternalRecordPrefix + recordSuffix | ||
kopsControllerInternal := &scalewaytasks.DNSRecord{ | ||
Name: fi.PtrTo(recordShortName), | ||
Data: fi.PtrTo(placeholderIP), | ||
DNSZone: fi.PtrTo(b.Cluster.Spec.DNSZone), | ||
Type: fi.PtrTo(domain.RecordTypeA.String()), | ||
TTL: fi.PtrTo(defaultTTL), | ||
Lifecycle: b.Lifecycle, | ||
} | ||
c.AddTask(kopsControllerInternal) | ||
|
||
return nil | ||
} |
Oops, something went wrong.