-
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.
- Loading branch information
Showing
31 changed files
with
864 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
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,24 @@ | ||
apiVersion: v2 | ||
name: ck-loadbalancer | ||
description: A Helm chart containing LoadBalancer manifests for Canonical Kubernetes | ||
|
||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
type: application | ||
|
||
# This is the chart version. This version number should be incremented each time you make changes | ||
# to the chart and its templates, including the app version. | ||
# Versions are expected to follow Semantic Versioning (https://semver.org/) | ||
version: 0.1.0 | ||
|
||
# This is the version number of the application being deployed. This version number should be | ||
# incremented each time you make changes to the application. Versions are not expected to | ||
# follow Semantic Versioning. They should reflect the version the application is using. | ||
# It is recommended to use it with quotes. | ||
appVersion: "0.1.0" |
62 changes: 62 additions & 0 deletions
62
k8s/components/charts/ck-loadbalancer/templates/_helpers.tpl
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,62 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "ck-loadbalancer.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "ck-loadbalancer.fullname" -}} | ||
{{- if .Values.fullnameOverride }} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- $name := default .Chart.Name .Values.nameOverride }} | ||
{{- if contains $name .Release.Name }} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "ck-loadbalancer.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "ck-loadbalancer.labels" -}} | ||
helm.sh/chart: {{ include "ck-loadbalancer.chart" . }} | ||
{{ include "ck-loadbalancer.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "ck-loadbalancer.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "ck-loadbalancer.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "ck-loadbalancer.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "ck-loadbalancer.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} |
18 changes: 18 additions & 0 deletions
18
k8s/components/charts/ck-loadbalancer/templates/bgp-policy.yaml
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,18 @@ | ||
{{- if .Values.bgp.enabled }} | ||
apiVersion: "cilium.io/v2alpha1" | ||
kind: CiliumBGPPeeringPolicy | ||
metadata: | ||
name: {{ include "ck-loadbalancer.fullname" . }} | ||
labels: | ||
{{- include "ck-loadbalancer.labels" . | nindent 4 }} | ||
spec: | ||
virtualRouters: | ||
- localASN: {{ .Values.bgp.localASN }} | ||
serviceSelector: | ||
matchExpressions: | ||
- {key: somekey, operator: NotIn, values: ['never-used-value']} | ||
{{- with .Values.bgp.neighbors }} | ||
neighbors: | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- end}} |
15 changes: 15 additions & 0 deletions
15
k8s/components/charts/ck-loadbalancer/templates/l2-policy.yaml
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,15 @@ | ||
{{- if .Values.l2.enabled }} | ||
apiVersion: "cilium.io/v2alpha1" | ||
kind: CiliumL2AnnouncementPolicy | ||
metadata: | ||
name: {{ include "ck-loadbalancer.fullname" . }} | ||
labels: | ||
{{- include "ck-loadbalancer.labels" . | nindent 4 }} | ||
spec: | ||
{{- with .Values.l2.interfaces }} | ||
interfaces: | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
externalIPs: true | ||
loadBalancerIPs: true | ||
{{- end }} |
13 changes: 13 additions & 0 deletions
13
k8s/components/charts/ck-loadbalancer/templates/lb-ip-pool.yaml
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,13 @@ | ||
{{- if .Values.ipPool.cidrs }} | ||
apiVersion: "cilium.io/v2alpha1" | ||
kind: CiliumLoadBalancerIPPool | ||
metadata: | ||
name: {{ include "ck-loadbalancer.fullname" . }} | ||
labels: | ||
{{- include "ck-loadbalancer.labels" . | nindent 4 }} | ||
spec: | ||
{{- with .Values.ipPool.cidrs }} | ||
cidrs: | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- end }} |
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,75 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema#", | ||
"type": "object", | ||
"properties": { | ||
"l2": { | ||
"type": "object", | ||
"properties": { | ||
"enabled": { | ||
"type": "boolean" | ||
}, | ||
"interfaces": { | ||
"type": [ "array", "null" ], | ||
"items": [ | ||
{ | ||
"type": "string" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"ipPool": { | ||
"type": "object", | ||
"properties": { | ||
"cidrs": { | ||
"type": "array", | ||
"items": [ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"cidr": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": ["cidr"] | ||
} | ||
] | ||
} | ||
}, | ||
"required": ["cidrs"] | ||
}, | ||
"bgp": { | ||
"type": "object", | ||
"properties": { | ||
"enabled": { | ||
"type": "boolean" | ||
}, | ||
"localASN": { | ||
"type": "integer" | ||
}, | ||
"neighbors": { | ||
"type": "array", | ||
"items": [ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"peerAddress": { | ||
"type": "string" | ||
}, | ||
"peerASN": { | ||
"type": "integer" | ||
}, | ||
"peerPort": { | ||
"type": "integer" | ||
} | ||
}, | ||
"required": ["peerAddress", "peerASN", "peerPort"] | ||
} | ||
] | ||
} | ||
}, | ||
"required": ["localASN", "neighbors"] | ||
} | ||
}, | ||
"required": ["l2", "ipPool", "bgp"] | ||
} |
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,20 @@ | ||
|
||
l2: | ||
enabled: true | ||
# interfaces: | ||
# - "^eth[0-9]+" | ||
interfaces: [] | ||
|
||
ipPool: | ||
# cidrs: | ||
# - cidr: "10.42.254.176/28" | ||
cidrs: [] | ||
|
||
bgp: | ||
enabled: false | ||
localASN: 64512 | ||
# neighbors: | ||
# - peerAddress: '10.0.0.60/24' | ||
# peerASN: 65100 | ||
# peerPort: 179 | ||
neighbors: [] |
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,35 @@ | ||
package k8s | ||
|
||
import ( | ||
"fmt" | ||
|
||
api "github.com/canonical/k8s/api/v1" | ||
"github.com/canonical/k8s/pkg/k8s/client" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var disableGatewayCmd = &cobra.Command{ | ||
Use: "gateway", | ||
Short: "Disable the Gateway component in the cluster.", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
client, err := client.NewClient(cmd.Context(), client.ClusterOpts{ | ||
StateDir: clusterCmdOpts.stateDir, | ||
Verbose: rootCmdOpts.logVerbose, | ||
Debug: rootCmdOpts.logDebug, | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("failed to create client: %w", err) | ||
} | ||
|
||
request := api.UpdateGatewayComponentRequest{ | ||
Status: api.ComponentDisable, | ||
} | ||
|
||
if err := client.UpdateGatewayComponent(cmd.Context(), request); err != nil { | ||
return fmt.Errorf("failed to disable Gateway component: %w", err) | ||
} | ||
|
||
cmd.Println("Component 'Gateway' disabled") | ||
return nil | ||
}, | ||
} |
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,35 @@ | ||
package k8s | ||
|
||
import ( | ||
"fmt" | ||
|
||
api "github.com/canonical/k8s/api/v1" | ||
"github.com/canonical/k8s/pkg/k8s/client" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var disableIngressCmd = &cobra.Command{ | ||
Use: "ingress", | ||
Short: "Disable the Ingress component in the cluster.", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
client, err := client.NewClient(cmd.Context(), client.ClusterOpts{ | ||
StateDir: clusterCmdOpts.stateDir, | ||
Verbose: rootCmdOpts.logVerbose, | ||
Debug: rootCmdOpts.logDebug, | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("failed to create client: %w", err) | ||
} | ||
|
||
request := api.UpdateIngressComponentRequest{ | ||
Status: api.ComponentDisable, | ||
} | ||
|
||
if err := client.UpdateIngressComponent(cmd.Context(), request); err != nil { | ||
return fmt.Errorf("failed to disable Ingress component: %w", err) | ||
} | ||
|
||
cmd.Println("Component 'Ingress' disabled") | ||
return nil | ||
}, | ||
} |
Oops, something went wrong.