-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Group feature implementations in a swappable interface (#417)
* Move features to subpackages * Group features behind a main implementation
- Loading branch information
1 parent
004575e
commit 723e369
Showing
17 changed files
with
227 additions
and
105 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package cilium | ||
|
||
import ( | ||
"path" | ||
|
||
"github.com/canonical/k8s/pkg/client/helm" | ||
) | ||
|
||
var ( | ||
// chartCilium represents manifests to deploy Cilium. | ||
chartCilium = helm.InstallableChart{ | ||
Name: "ck-network", | ||
Namespace: "kube-system", | ||
ManifestPath: path.Join("charts", "cilium-1.15.2.tgz"), | ||
} | ||
|
||
// chartCiliumLoadBalancer represents manifests to deploy Cilium LoadBalancer resources. | ||
chartCiliumLoadBalancer = helm.InstallableChart{ | ||
Name: "ck-loadbalancer", | ||
Namespace: "kube-system", | ||
ManifestPath: path.Join("charts", "ck-loadbalancer"), | ||
} | ||
|
||
// chartGateway represents manifests to deploy Gateway API CRDs. | ||
chartGateway = helm.InstallableChart{ | ||
Name: "ck-gateway", | ||
Namespace: "kube-system", | ||
ManifestPath: path.Join("charts", "gateway-api-1.0.0.tgz"), | ||
} | ||
|
||
// ciliumAgentImageRepo represents the image to use for cilium-agent. | ||
ciliumAgentImageRepo = "ghcr.io/canonical/cilium" | ||
|
||
// ciliumAgentImageTag is the tag to use for the cilium-agent image. | ||
ciliumAgentImageTag = "1.15.2-ck1" | ||
|
||
// ciliumOperatorImageRepo is the image to use for cilium-operator. | ||
ciliumOperatorImageRepository = "ghcr.io/canonical/cilium-operator" | ||
|
||
// ciliumOperatorImageTag is the tag to use for the cilium-operator image. | ||
ciliumOperatorImageTag = "1.15.2-ck1" | ||
) |
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,22 @@ | ||
package coredns | ||
|
||
import ( | ||
"path" | ||
|
||
"github.com/canonical/k8s/pkg/client/helm" | ||
) | ||
|
||
var ( | ||
// chartCoreDNS represents manifests to deploy CoreDNS. | ||
chart = helm.InstallableChart{ | ||
Name: "ck-dns", | ||
Namespace: "kube-system", | ||
ManifestPath: path.Join("charts", "coredns-1.29.0.tgz"), | ||
} | ||
|
||
// imageRepo is the image to use for CoreDNS. | ||
imageRepo = "ghcr.io/canonical/coredns" | ||
|
||
// imageTag is the tag to use for the CoreDNS image. | ||
imageTag = "1.11.1-ck4" | ||
) |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,23 @@ | ||
package features | ||
|
||
import ( | ||
"github.com/canonical/k8s/pkg/k8sd/features/cilium" | ||
"github.com/canonical/k8s/pkg/k8sd/features/coredns" | ||
"github.com/canonical/k8s/pkg/k8sd/features/localpv" | ||
metrics_server "github.com/canonical/k8s/pkg/k8sd/features/metrics-server" | ||
) | ||
|
||
// Default implements the Canonical Kubernetes built-in features. | ||
// Cilium is used for networking (network + load-balancer + ingress + gateway). | ||
// CoreDNS is used for DNS. | ||
// MetricsServer is used for metrics-server. | ||
// LocalPV Rawfile CSI is used for local-storage. | ||
var Implementation Interface = &implementation{ | ||
applyDNS: coredns.ApplyDNS, | ||
applyNetwork: cilium.ApplyNetwork, | ||
applyLoadBalancer: cilium.ApplyLoadBalancer, | ||
applyIngress: cilium.ApplyIngress, | ||
applyGateway: cilium.ApplyGateway, | ||
applyMetricsServer: metrics_server.ApplyMetricsServer, | ||
applyLocalStorage: localpv.ApplyLocalStorage, | ||
} |
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,65 @@ | ||
package features | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/canonical/k8s/pkg/k8sd/types" | ||
"github.com/canonical/k8s/pkg/snap" | ||
) | ||
|
||
// Interface abstracts the management of built-in Canonical Kubernetes features. | ||
type Interface interface { | ||
// ApplyDNS is used to configure the DNS feature on Canonical Kubernetes. | ||
ApplyDNS(context.Context, snap.Snap, types.DNS, types.Kubelet) (string, error) | ||
// ApplyNetwork is used to configure the network feature on Canonical Kubernetes. | ||
ApplyNetwork(context.Context, snap.Snap, types.Network) error | ||
// ApplyLoadBalancer is used to configure the load-balancer feature on Canonical Kubernetes. | ||
ApplyLoadBalancer(context.Context, snap.Snap, types.LoadBalancer, types.Network) error | ||
// ApplyIngress is used to configure the ingress controller feature on Canonical Kubernetes. | ||
ApplyIngress(context.Context, snap.Snap, types.Ingress, types.Network) error | ||
// ApplyGateway is used to configure the gateway feature on Canonical Kubernetes. | ||
ApplyGateway(context.Context, snap.Snap, types.Gateway, types.Network) error | ||
// ApplyMetricsServer is used to configure the metrics-server feature on Canonical Kubernetes. | ||
ApplyMetricsServer(context.Context, snap.Snap, types.MetricsServer) error | ||
// ApplyLocalStorage is used to configure the Local Storage feature on Canonical Kubernetes. | ||
ApplyLocalStorage(context.Context, snap.Snap, types.LocalStorage) error | ||
} | ||
|
||
// implementation implements Interface. | ||
type implementation struct { | ||
applyDNS func(context.Context, snap.Snap, types.DNS, types.Kubelet) (string, error) | ||
applyNetwork func(context.Context, snap.Snap, types.Network) error | ||
applyLoadBalancer func(context.Context, snap.Snap, types.LoadBalancer, types.Network) error | ||
applyIngress func(context.Context, snap.Snap, types.Ingress, types.Network) error | ||
applyGateway func(context.Context, snap.Snap, types.Gateway, types.Network) error | ||
applyMetricsServer func(context.Context, snap.Snap, types.MetricsServer) error | ||
applyLocalStorage func(context.Context, snap.Snap, types.LocalStorage) error | ||
} | ||
|
||
func (i *implementation) ApplyDNS(ctx context.Context, snap snap.Snap, dns types.DNS, kubelet types.Kubelet) (string, error) { | ||
return i.applyDNS(ctx, snap, dns, kubelet) | ||
} | ||
|
||
func (i *implementation) ApplyNetwork(ctx context.Context, snap snap.Snap, cfg types.Network) error { | ||
return i.applyNetwork(ctx, snap, cfg) | ||
} | ||
|
||
func (i *implementation) ApplyLoadBalancer(ctx context.Context, snap snap.Snap, loadbalancer types.LoadBalancer, network types.Network) error { | ||
return i.applyLoadBalancer(ctx, snap, loadbalancer, network) | ||
} | ||
|
||
func (i *implementation) ApplyIngress(ctx context.Context, snap snap.Snap, ingress types.Ingress, network types.Network) error { | ||
return i.applyIngress(ctx, snap, ingress, network) | ||
} | ||
|
||
func (i *implementation) ApplyGateway(ctx context.Context, snap snap.Snap, gateway types.Gateway, network types.Network) error { | ||
return i.applyGateway(ctx, snap, gateway, network) | ||
} | ||
|
||
func (i *implementation) ApplyMetricsServer(ctx context.Context, snap snap.Snap, cfg types.MetricsServer) error { | ||
return i.applyMetricsServer(ctx, snap, cfg) | ||
} | ||
|
||
func (i *implementation) ApplyLocalStorage(ctx context.Context, snap snap.Snap, cfg types.LocalStorage) error { | ||
return i.applyLocalStorage(ctx, snap, cfg) | ||
} |
Oops, something went wrong.