mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-26 10:40:58 +00:00

* k8s-operator,cmd/k8s-operator,Makefile,scripts,.github/workflows: add Connector kube CRD. Connector CRD allows users to configure the Tailscale Kubernetes operator to deploy a subnet router to expose cluster CIDRs or other CIDRs available from within the cluster to their tailnet. Also adds various CRD related machinery to generate CRD YAML, deep copy implementations etc. Engineers will now have to run 'make kube-generate-all` after changing kube files to ensure that all generated files are up to date. * cmd/k8s-operator,k8s-operator: reconcile Connector resources Reconcile Connector resources, create/delete subnetrouter resources in response to changes to Connector(s). Connector reconciler will not be started unless ENABLE_CONNECTOR env var is set to true. This means that users who don't want to use the alpha Connector custom resource don't have to install the Connector CRD to their cluster. For users who do want to use it the flow is: - install the CRD - install the operator (via Helm chart or using static manifests). For Helm users set .values.enableConnector to true, for static manifest users, set ENABLE_CONNECTOR to true in the static manifest. Updates tailscale/tailscale#502 Signed-off-by: Irbe Krumina <irbe@tailscale.com>
57 lines
1.6 KiB
Go
57 lines
1.6 KiB
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
//go:build !plan9
|
|
|
|
package v1alpha1
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"tailscale.com/k8s-operator/apis"
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/apimachinery/pkg/runtime"
|
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
"k8s.io/client-go/kubernetes/scheme"
|
|
)
|
|
|
|
// SchemeGroupVersion is group version used to register these objects
|
|
var SchemeGroupVersion = schema.GroupVersion{Group: apis.GroupName, Version: "v1alpha1"}
|
|
|
|
// Resource takes an unqualified resource and returns a Group qualified GroupResource
|
|
func Resource(resource string) schema.GroupResource {
|
|
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
|
}
|
|
|
|
var (
|
|
SchemeBuilder runtime.SchemeBuilder
|
|
localSchemeBuilder = &SchemeBuilder
|
|
AddToScheme = localSchemeBuilder.AddToScheme
|
|
|
|
GlobalScheme *runtime.Scheme
|
|
)
|
|
|
|
func init() {
|
|
// We only register manually written functions here. The registration of the
|
|
// generated functions takes place in the generated files. The separation
|
|
// makes the code compile even when the generated files are missing.
|
|
localSchemeBuilder.Register(addKnownTypes)
|
|
|
|
GlobalScheme = runtime.NewScheme()
|
|
if err := scheme.AddToScheme(GlobalScheme); err != nil {
|
|
panic(fmt.Sprintf("failed to add k8s.io scheme: %s", err))
|
|
}
|
|
if err := AddToScheme(GlobalScheme); err != nil {
|
|
panic(fmt.Sprintf("failed to add tailscale.com scheme: %s", err))
|
|
}
|
|
}
|
|
|
|
// Adds the list of known types to api.Scheme.
|
|
func addKnownTypes(scheme *runtime.Scheme) error {
|
|
scheme.AddKnownTypes(SchemeGroupVersion, &Connector{}, &ConnectorList{})
|
|
|
|
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
|
return nil
|
|
}
|