kubernetes

package
v0.0.0-...-3d7b588 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckForCertExpiry

func CheckForCertExpiry()

Check and warn if cert expiry is less than `warningDaysForCertExpiry` days.

func CheckPodExists

func CheckPodExists(client k8s.Interface, namespace string, labelSelector map[string]string, deployName string) (bool, string)

CheckPodExists returns a boolean representing the pod's existence and the namespace that the given pod resides in, or empty if not present in the given namespace.

func Client

func Client() (*k8s.Clientset, error)

Client returns a new Kubernetes client.

func DaprClient

func DaprClient() (scheme.Interface, error)

DaprClient returns a new Kubernetes Dapr client.

func Expiry

func Expiry() (*time.Time, error)

Expiry returns the expiry time for the root cert.

func ExportTrustChain

func ExportTrustChain(outputDir string) error

ExportTrustChain takes the root cert, issuer cert and issuer key from a k8s cluster and saves them in a given directory.

func GenerateNewCertificates

func GenerateNewCertificates(validUntil time.Duration, privateKeyFile string) ([]byte, []byte, []byte, error)

func GetDaprControlPlaneCurrentConfig

func GetDaprControlPlaneCurrentConfig() (*v1alpha1.Configuration, error)

func GetDaprHelmChartName

func GetDaprHelmChartName(helmConf *helm.Configuration) (string, error)

func GetDaprNamespace

func GetDaprNamespace() (string, error)

func GetDaprVersion

func GetDaprVersion(status []StatusOutput) string

func GetDefaultConfiguration

func GetDefaultConfiguration() v1alpha1.Configuration

func GetImageRegistry

func GetImageRegistry() (string, error)

func GetKubeConfigClient

func GetKubeConfigClient() (*rest.Config, *k8s.Clientset, error)

GetKubeConfigClient returns the kubeconfig and the client created from the kubeconfig.

func Init

func Init(config InitConfiguration) error

Init deploys the Dapr operator using the supplied runtime version.

func IsDashboardIncluded

func IsDashboardIncluded(runtimeVersion string) (bool, error)

IsDashboardIncluded returns true if dashboard is included in Helm chart version for Dapr.

func IsMTLSEnabled

func IsMTLSEnabled() (bool, error)

func ListPods

func ListPods(client *k8s.Clientset, namespace string, labelSelector map[string]string) (*corev1.PodList, error)

func ListPodsInterface

func ListPodsInterface(client k8s.Interface, labelSelector map[string]string) (*corev1.PodList, error)

func Logs

func Logs(appID, podName, namespace string) error

Logs fetches Dapr sidecar logs from Kubernetes.

func PrintComponents

func PrintComponents(name, namespace, outputFormat string) error

PrintComponents prints all Dapr components.

func PrintConfigurations

func PrintConfigurations(name, namespace, outputFormat string) error

PrintConfigurations prints all Dapr configurations.

func RenewCertificate

func RenewCertificate(conf RenewCertificateParams) error

func Run

func Run(runFilePath string, config runfileconfig.RunFileConfig) (bool, error)

Run executes the application based on the run file configuration. Run creates a temporary `deploy` folder within the app/.dapr directory and then applies that to the context pointed to kubectl client.

func Stop

func Stop(runFilePath string, config runfileconfig.RunFileConfig) error

func Uninstall

func Uninstall(namespace string, uninstallAll bool, uninstallDev bool, timeout uint) error

Uninstall removes Dapr from a Kubernetes cluster.

func Upgrade

func Upgrade(conf UpgradeConfig) error

Types

type AnnotateOptions

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

AnnotateOptions configure the injection behavior.

func NewAnnotateOptions

func NewAnnotateOptions(opts ...AnnoteOption) AnnotateOptions

type Annotator

type Annotator interface {
	Annotate(io.Reader, io.Writer) error
}

type AnnoteOption

type AnnoteOption func(*AnnotateOptions)

func WithAPITokenSecret

func WithAPITokenSecret(apiTokenSecret string) AnnoteOption

func WithAppID

func WithAppID(appID string) AnnoteOption

func WithAppMaxConcurrency

func WithAppMaxConcurrency(maxConcurrency int) AnnoteOption

func WithAppPort

func WithAppPort(port int) AnnoteOption

func WithAppProtocol

func WithAppProtocol(protocol string) AnnoteOption

func WithAppSSL

func WithAppSSL() AnnoteOption

func WithAppTokenSecret

func WithAppTokenSecret(appTokenSecret string) AnnoteOption

func WithCPULimit

func WithCPULimit(cpuLimit string) AnnoteOption

func WithCPURequest

func WithCPURequest(cpuRequest string) AnnoteOption

func WithConfig

func WithConfig(cfg string) AnnoteOption

func WithDaprImage

func WithDaprImage(image string) AnnoteOption

func WithDebugEnabled

func WithDebugEnabled() AnnoteOption

func WithDebugPort

func WithDebugPort(debugPort int) AnnoteOption

func WithDisableBuiltinK8sSecretStore

func WithDisableBuiltinK8sSecretStore() AnnoteOption

func WithEnableAPILogging

func WithEnableAPILogging() AnnoteOption

func WithEnv

func WithEnv(env string) AnnoteOption

func WithGracefulShutdownSeconds

func WithGracefulShutdownSeconds(gracefulShutdownSeconds int) AnnoteOption

func WithHTTPStreamRequestBody

func WithHTTPStreamRequestBody() AnnoteOption

func WithListenAddresses

func WithListenAddresses(listenAddresses string) AnnoteOption

func WithLivenessProbeDelay

func WithLivenessProbeDelay(livenessProbeDelay int) AnnoteOption

func WithLivenessProbePeriod

func WithLivenessProbePeriod(livenessProbePeriod int) AnnoteOption

func WithLivenessProbeThreshold

func WithLivenessProbeThreshold(livenessProbeThreshold int) AnnoteOption

func WithLivenessProbeTimeout

func WithLivenessProbeTimeout(livenessProbeTimeout int) AnnoteOption

func WithLogAsJSON

func WithLogAsJSON() AnnoteOption

func WithLogLevel

func WithLogLevel(logLevel string) AnnoteOption

func WithMaxRequestBodySize

func WithMaxRequestBodySize(maxRequestBodySize int) AnnoteOption

func WithMemoryLimit

func WithMemoryLimit(memoryLimit string) AnnoteOption

func WithMemoryRequest

func WithMemoryRequest(memoryRequest string) AnnoteOption

func WithMetricsEnabled

func WithMetricsEnabled() AnnoteOption

func WithMetricsPort

func WithMetricsPort(port int) AnnoteOption

func WithPlacementHostAddress

func WithPlacementHostAddress(placementHostAddress string) AnnoteOption

func WithProfileEnabled

func WithProfileEnabled() AnnoteOption

func WithReadBufferSize

func WithReadBufferSize(readBufferSize int) AnnoteOption

func WithReadinessProbeDelay

func WithReadinessProbeDelay(readinessProbeDelay int) AnnoteOption

func WithReadinessProbePeriod

func WithReadinessProbePeriod(readinessProbePeriod int) AnnoteOption

func WithReadinessProbeThreshold

func WithReadinessProbeThreshold(readinessProbeThreshold int) AnnoteOption

func WithReadinessProbeTimeout

func WithReadinessProbeTimeout(readinessProbeTimeout int) AnnoteOption

func WithUnixDomainSocketPath

func WithUnixDomainSocketPath(unixDomainSocketPath string) AnnoteOption

func WithVolumeMountsReadOnly

func WithVolumeMountsReadOnly(volumeMountsReadOnly string) AnnoteOption

func WithVolumeMountsReadWrite

func WithVolumeMountsReadWrite(volumeMountsReadWrite string) AnnoteOption

type ComponentsOutput

type ComponentsOutput struct {
	Namespace string `csv:"Namespace"`
	Name      string `csv:"Name"`
	Type      string `csv:"Type"`
	Version   string `csv:"VERSION"`
	Scopes    string `csv:"SCOPES"`
	Created   string `csv:"CREATED"`
	Age       string `csv:"AGE"`
}

ComponentsOutput represent a Dapr component.

type InitConfiguration

type InitConfiguration struct {
	Version                   string
	DashboardVersion          string
	Namespace                 string
	EnableMTLS                bool
	EnableHA                  bool
	EnableDev                 bool
	Args                      []string
	Wait                      bool
	Timeout                   uint
	ImageRegistryURI          string
	ImageVariant              string
	RootCertificateFilePath   string
	IssuerCertificateFilePath string
	IssuerPrivateKeyFilePath  string
}

type K8sAnnotator

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

func NewK8sAnnotator

func NewK8sAnnotator(config K8sAnnotatorConfig) *K8sAnnotator

func (*K8sAnnotator) Annotate

func (p *K8sAnnotator) Annotate(inputs []io.Reader, out io.Writer, opts AnnotateOptions) error

Annotate injects dapr annotations into the kubernetes resource.

type K8sAnnotatorConfig

type K8sAnnotatorConfig struct {
	// If TargetResource is set, we will search for it and then inject
	// annotations on that target resource. If it is not set, we will
	// update the first appropriate resource we find.
	TargetResource *string
	// If TargetNamespace is set, we will search for the target resource
	// in the provided target namespace. If it is not set, we will
	// just search for the first occurrence of the target resource.
	TargetNamespace *string
}

type ListOutput

type ListOutput struct {
	Namespace string `csv:"NAMESPACE" json:"namespace" yaml:"namespace"`
	AppID     string `csv:"APP ID"    json:"appId"     yaml:"appId"`
	AppPort   string `csv:"APP PORT"  json:"appPort"   yaml:"appPort"`
	Age       string `csv:"AGE"       json:"age"       yaml:"age"`
	Created   string `csv:"CREATED"   json:"created"   yaml:"created"`
}

ListOutput represents the application ID, application port and creation time.

func List

func List(namespace string) ([]ListOutput, error)

List outputs all the applications.

type NamespacedObject

type NamespacedObject interface {
	GetNamespace() string
}

type PortForward

type PortForward struct {
	Config     *rest.Config
	Method     string
	URL        *url.URL
	Host       string
	LocalPort  int
	RemotePort int
	EmitLogs   bool
	StopCh     chan struct{}
	ReadyCh    chan struct{}
}

PortForward provides a port-forward connection in a kubernetes cluster.

func NewPortForward

func NewPortForward(
	config *rest.Config,
	namespace, deployName string,
	host string, localPort, remotePort int,
	emitLogs bool,
) (*PortForward, error)

NewPortForward returns an instance of PortForward struct that can be used for establishing port-forwarding connection to a pod in kubernetes cluster, specified by namespace and deployName.

func (*PortForward) GetStop

func (pf *PortForward) GetStop() <-chan struct{}

GetStop returns StopCh for a PortForward instance. Receiving on StopCh will block until the port forwarding stops.

func (*PortForward) Init

func (pf *PortForward) Init() error

Init creates and runs a port-forward connection. This function blocks until connection is established. Note: Caller should call Stop() to finish the connection.

func (*PortForward) Stop

func (pf *PortForward) Stop()

Stop terminates port-forwarding connection.

type RenewCertificateParams

type RenewCertificateParams struct {
	RootCertificateFilePath   string
	IssuerCertificateFilePath string
	IssuerPrivateKeyFilePath  string
	RootPrivateKeyFilePath    string
	ValidUntil                time.Duration
	Timeout                   uint
	ImageVariant              string
}

type StatusClient

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

func NewStatusClient

func NewStatusClient() (*StatusClient, error)

Create a new k8s client for status commands.

func (*StatusClient) Status

func (s *StatusClient) Status() ([]StatusOutput, error)

List status for Dapr resources.

type StatusOutput

type StatusOutput struct {
	Name      string `csv:"NAME"`
	Namespace string `csv:"NAMESPACE"`
	Healthy   string `csv:"HEALTHY"`
	Status    string `csv:"STATUS"`
	Replicas  int    `csv:"REPLICAS"`
	Version   string `csv:"VERSION"`
	Age       string `csv:"AGE"`
	Created   string `csv:"CREATED"`
}

StatusOutput represents the status of a named Dapr resource.

func GetDaprResourcesStatus

func GetDaprResourcesStatus() ([]StatusOutput, error)

type UpgradeConfig

type UpgradeConfig struct {
	RuntimeVersion   string
	DashboardVersion string
	Args             []string
	Timeout          uint
	ImageRegistryURI string
	ImageVariant     string
}

Jump to

Keyboard shortcuts

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