k8sclient

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EntryPointWeb       = "web"
	EntryPointWebSecure = "websecure"
)
View Source
const (
	LetsEncryptStaging      = "https://acme-staging-v02.api.letsencrypt.org/directory"
	DefaultIngressRouteName = "ingressroute"
)

Variables

View Source
var (
	DefaultNamespace      = assets.AppName
	DefaultCertName       = fmt.Sprintf("%s-root-domain", assets.AppName)
	DefaultClusterIssuer  = fmt.Sprintf("%s-clusterissuer", assets.AppName)
	DefaultCertSecretName = "%s-cert-secret"
	DefaultServiceName    = "%s-%s-svc"
)

Functions

func CreateCertSecretName

func CreateCertSecretName(name string) string

func CreateLabels

func CreateLabels(opts ...LabelOpt) map[string]string

func GetKubeConfig

func GetKubeConfig() (*rest.Config, error)

GetKubeConfig checks whether KUBECONFIG environment variable is set. If it is set, uses it as kubeconfig. if it isn't, falls back to InClusterConfig.

func NewCertificate

func NewCertificate(name, namespace string, opts ...CertificateOption) *cm.Certificate

func NewClusterIssuer

func NewClusterIssuer(opts ...ClusterIssuerOption) *cm.ClusterIssuer

func NewIngressRoute

func NewIngressRoute(
	name, namespace string,
	opts ...IngressRouteOption,
) *traefikv1alpha1.IngressRoute

Types

type CertificateOption

type CertificateOption func(c *cm.Certificate)

func WithCertificateDomain

func WithCertificateDomain(domain string) CertificateOption

func WithCertificateKind

func WithCertificateKind(kind string) CertificateOption

func WithCertificateName

func WithCertificateName(name string) CertificateOption

type ClusterIssuerOption

type ClusterIssuerOption func(*cm.ClusterIssuer)

func WithClusterIssuerACMEDNS01

func WithClusterIssuerACMEDNS01(
	email, server, name, apikeyName, apikeyRef string,
	dnsZones []string,
) ClusterIssuerOption

func WithClusterIssuerACMEHTTP01

func WithClusterIssuerACMEHTTP01(email, name string) ClusterIssuerOption

func WithClusterIssuerCustomName

func WithClusterIssuerCustomName(name string) ClusterIssuerOption

func WithClusterIssuerSelfSigned

func WithClusterIssuerSelfSigned() ClusterIssuerOption

type GVR

type GVR struct {
	// contains filtered or unexported fields
}

GVR is a kubernetes resource schema Fields are group/version/resources:subresource

func NewGVR

func NewGVR(gvr string) *GVR

NewGVR creates a GVR from a group, version, resource

func (GVR) G

func (g GVR) G() string

G returns the resource group name.

func (GVR) GR

func (g GVR) GR() *schema.GroupResource

GR returns a full schema representation.

func (GVR) GV

func (g GVR) GV() schema.GroupVersion

GV returns the group version scheme representation.

func (GVR) GVK

func (g GVR) GVK() schema.GroupVersionKind

GVK returns a full schema representation.

func (GVR) GVR

GVR returns a full schema representation.

func (GVR) R

func (g GVR) R() string

R returns the resource name.

func (GVR) RG

func (g GVR) RG() (string, string)

RG returns the resource and group.

func (GVR) V

func (g GVR) V() string

V returns the resource version.

type IngressRouteOption

type IngressRouteOption func(*traefikv1alpha1.IngressRoute)

func WithIngressRouteEntryPoint

func WithIngressRouteEntryPoint(entryType string) IngressRouteOption

func WithIngressRouteRule

func WithIngressRouteRule(
	match, svcName, svcNamespace string,
	middlewareRefs []string,
	svcPort int32,
) IngressRouteOption

func WithIngressRouteTLS

func WithIngressRouteTLS(secretName string) IngressRouteOption

type K8sClient

type K8sClient struct {
	DynamicClient *dynamic.DynamicClient
	Client        *kubernetes.Clientset
	// contains filtered or unexported fields
}

func NewK8sClient

func NewK8sClient(isDebug, isConsole bool) *K8sClient

func (K8sClient) CreateCertificate

func (k K8sClient) CreateCertificate(
	ctx context.Context,
	name, namespace string,
	opts ...CertificateOption,
) (*cm.Certificate, error)

func (K8sClient) CreateClusterIssuer

func (k K8sClient) CreateClusterIssuer(
	ctx context.Context,
	opts ...ClusterIssuerOption,
) (*cm.ClusterIssuer, error)

func (K8sClient) CreateIngress

func (k K8sClient) CreateIngress(
	ctx context.Context,
	name, namespace string,
	opts ...IngressRouteOption,
) (*traefikv1alpha1.IngressRoute, error)

func (K8sClient) GetCertificate

func (k K8sClient) GetCertificate(
	ctx context.Context,
	name, namespace string,
) (*v1.Service, error)

func (K8sClient) GetDeployment

func (k K8sClient) GetDeployment(
	ctx context.Context,
	name, namespace string,
) (*appsv1.Deployment, error)

func (K8sClient) GetService

func (k K8sClient) GetService(ctx context.Context, name, namespace string) (*v1.Service, error)

func (K8sClient) ListCertificates

func (k K8sClient) ListCertificates(
	ctx context.Context,
	namespace string,
) (*unstructured.UnstructuredList, error)

func (K8sClient) ListDeployments

func (k K8sClient) ListDeployments(
	ctx context.Context,
	namespace string,
) (*appsv1.DeploymentList, error)

func (K8sClient) ListIngresses

func (k K8sClient) ListIngresses(
	ctx context.Context,
	namespace string,
) (*unstructured.UnstructuredList, error)

func (K8sClient) ListPods

func (k K8sClient) ListPods(ctx context.Context, namespace string) (*v1.PodList, error)

func (K8sClient) ListServices

func (k K8sClient) ListServices(ctx context.Context, namespace string) (*v1.ServiceList, error)

func (K8sClient) UpdateCertificate

func (k K8sClient) UpdateCertificate(
	ctx context.Context,
	name, namespace string,
	opts ...CertificateOption,
) (*cm.Certificate, error)

func (K8sClient) UpdateClusterIssuer

func (k K8sClient) UpdateClusterIssuer(
	ctx context.Context,
	name string,
	opts ...ClusterIssuerOption,
) (*cm.ClusterIssuer, error)

func (K8sClient) UpdateIngress

func (k K8sClient) UpdateIngress(
	ctx context.Context,
	name, namespace string,
	opts ...IngressRouteOption,
) (*traefikv1alpha1.IngressRoute, error)

type LabelOpt

type LabelOpt func(*LabelOpts)

func WithComponent

func WithComponent(component string) LabelOpt

func WithCoreLabel

func WithCoreLabel(core bool) LabelOpt

func WithCustomLabel

func WithCustomLabel(key, value string) LabelOpt

func WithName

func WithName(name string) LabelOpt

type LabelOpts

type LabelOpts struct {
	Extra     map[string]string
	Name      string
	Component string
	Core      bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL