Skip to content

Commit 3a1b67a

Browse files
committed
feat(linode): add cloud foundation and LoadBalancer task
Signed-off-by: Moshe Vayner <moshe@vayner.me>
1 parent cfb47e3 commit 3a1b67a

File tree

11 files changed

+2113
-5
lines changed

11 files changed

+2113
-5
lines changed

pkg/model/linodemodel/OWNERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# See the OWNERS docs at <https://go.k8s.io/owners>
2+
3+
labels:
4+
5+
- area/provider/linode
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
Copyright 2026 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package linodemodel
18+
19+
import (
20+
"fmt"
21+
22+
"k8s.io/kops/pkg/apis/kops"
23+
"k8s.io/kops/pkg/dns"
24+
"k8s.io/kops/pkg/wellknownservices"
25+
"k8s.io/kops/upup/pkg/fi"
26+
cloudlinode "k8s.io/kops/upup/pkg/fi/cloudup/linode"
27+
"k8s.io/kops/upup/pkg/fi/cloudup/linodetasks"
28+
)
29+
30+
// APILoadBalancerModelBuilder builds a Linode (Akamai) load balancer for API access.
31+
type APILoadBalancerModelBuilder struct {
32+
*LinodeModelContext
33+
Lifecycle fi.Lifecycle
34+
}
35+
36+
var _ fi.CloudupModelBuilder = &APILoadBalancerModelBuilder{}
37+
38+
func (b *APILoadBalancerModelBuilder) Build(c *fi.CloudupModelBuilderContext) error {
39+
if !b.UseLoadBalancerForAPI() {
40+
return nil
41+
}
42+
43+
if len(b.Cluster.Spec.Networking.Subnets) == 0 || b.Cluster.Spec.Networking.Subnets[0].Region == "" {
44+
return fmt.Errorf("linode API load balancer requires at least one subnet with a region")
45+
}
46+
47+
lb := &linodetasks.LoadBalancer{
48+
Name: fi.PtrTo("api." + b.ClusterName()),
49+
Lifecycle: b.Lifecycle,
50+
Region: fi.PtrTo(b.Cluster.Spec.Networking.Subnets[0].Region),
51+
Tags: []string{
52+
cloudlinode.BuildLinodeTag(kops.LabelClusterName, b.ClusterName()),
53+
},
54+
WellKnownServices: []wellknownservices.WellKnownService{wellknownservices.KubeAPIServer},
55+
}
56+
57+
if dns.IsGossipClusterName(b.Cluster.Name) || b.Cluster.UsesPrivateDNS() || b.Cluster.UsesNoneDNS() {
58+
lb.WellKnownServices = append(lb.WellKnownServices, wellknownservices.KopsController)
59+
}
60+
61+
c.AddTask(lb)
62+
63+
backendReconcile := &linodetasks.LoadBalancerBackends{
64+
Name: fi.PtrTo("backends." + fi.ValueOf(lb.Name)),
65+
Lifecycle: b.Lifecycle,
66+
LoadBalancer: lb,
67+
}
68+
c.AddTask(backendReconcile)
69+
70+
return nil
71+
}

pkg/model/linodemodel/context.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Copyright 2026 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package linodemodel
18+
19+
import "k8s.io/kops/pkg/model"
20+
21+
// LinodeModelContext holds shared model context for Linode (Akamai) builders.
22+
type LinodeModelContext struct {
23+
*model.KopsModelContext
24+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
Copyright 2026 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package linode
18+
19+
import "k8s.io/kops/upup/pkg/fi"
20+
21+
// APITarget runs cloudup tasks directly against Linode (Akamai) APIs.
22+
type APITarget struct {
23+
Cloud LinodeCloud
24+
}
25+
26+
var _ fi.CloudupTarget = &APITarget{}
27+
28+
// NewAPITarget builds a Linode (Akamai) target implementation.
29+
func NewAPITarget(cloud LinodeCloud) *APITarget {
30+
return &APITarget{Cloud: cloud}
31+
}
32+
33+
func (t *APITarget) Finish(taskMap map[string]fi.CloudupTask) error {
34+
return nil
35+
}
36+
37+
func (t *APITarget) DefaultCheckExisting() bool {
38+
return true
39+
}

0 commit comments

Comments
 (0)