Documentation ¶
Index ¶
- Constants
- Variables
- func DetectKubeConfig(configfile []byte) (config *rest.Config, err error)
- func ErrApplyHelmChart(err error) error
- func ErrApplyManifest(err error) error
- func ErrNewDiscovery(err error) error
- func ErrNewDynClient(err error) error
- func ErrNewInformer(err error) error
- func ErrNewKubeClient(err error) error
- func ErrServiceDiscovery(err error) error
- func GetEndpoint(ctx context.Context, opts *ServiceOptions, obj *corev1.Service) (*utils.Endpoint, error)
- func GetObjectFromManifest(manifest string) (runtime.Object, *unstructured.Unstructured, error)
- func GetServiceEndpoint(ctx context.Context, client kubernetes.Interface, opts *ServiceOptions) (*utils.Endpoint, error)
- type ApplyHelmChartConfig
- type ApplyOptions
- type Client
- type HelmChartLocation
- type HelmDriver
- type ServiceOptions
Constants ¶
const ( // Stable is the default repository for helm v3 Stable = "https://charts.helm.sh/stable" // Latest is the default version for helm charts Latest = ">0.0.0-0" )
Variables ¶
var ( ErrApplyManifestCode = "test_code" ErrServiceDiscoveryCode = "test_code" ErrApplyHelmChartCode = "test_code" ErrNewKubeClientCode = "test_code" ErrNewDynClientCode = "test_code" ErrNewDiscoveryCode = "test_code" ErrNewInformerCode = "test_code" ErrEndpointNotFoundCode = "test_code" ErrInvalidAPIServerCode = "test_code" ErrEndpointNotFound = errors.NewDefault(ErrEndpointNotFoundCode, "Unable to discover an endpoint") ErrInvalidAPIServer = errors.NewDefault(ErrInvalidAPIServerCode, "Invalid API Server URL") )
Functions ¶
func DetectKubeConfig ¶ added in v0.1.27
DetectKubeConfig detects the kubeconfig for the kubernetes cluster and returns it
func ErrApplyHelmChart ¶ added in v0.1.31
ErrApplyHelmChart is the error which occurs in the process of applying helm chart
func ErrApplyManifest ¶
func ErrNewDiscovery ¶ added in v0.2.1
ErrApplyHelmChart is the error which occurs in the process of applying helm chart
func ErrNewDynClient ¶ added in v0.2.1
ErrApplyHelmChart is the error which occurs in the process of applying helm chart
func ErrNewInformer ¶ added in v0.2.1
ErrApplyHelmChart is the error which occurs in the process of applying helm chart
func ErrNewKubeClient ¶ added in v0.2.1
ErrApplyHelmChart is the error which occurs in the process of applying helm chart
func ErrServiceDiscovery ¶ added in v0.1.22
ErrServiceDiscovery returns an error of type "ErrServiceDiscovery" along with the passed error
func GetEndpoint ¶ added in v0.2.3
func GetEndpoint(ctx context.Context, opts *ServiceOptions, obj *corev1.Service) (*utils.Endpoint, error)
GetEndpoint returns those endpoints in the given service which match the selector. Eg: service name = "client"
func GetObjectFromManifest ¶ added in v0.1.32
func GetObjectFromManifest(manifest string) (runtime.Object, *unstructured.Unstructured, error)
func GetServiceEndpoint ¶ added in v0.2.3
func GetServiceEndpoint(ctx context.Context, client kubernetes.Interface, opts *ServiceOptions) (*utils.Endpoint, error)
GetServiceEndpoint returns the endpoint for the given service
Types ¶
type ApplyHelmChartConfig ¶ added in v0.1.31
type ApplyHelmChartConfig struct { // ChartLocation is the remote location of the helm chart // // Either ChartLocation or URL can be defined, if both of them // are defined then URL is given the preferenece ChartLocation HelmChartLocation // URL is the url for charts // // Either ChartLocation or URL can be defined, if both of them // are defined then URL is given the preferenece URL string // HelmDriver is used to determine the backend // informations used by helm for managing release // // Defaults to Secret HelmDriver HelmDriver // SQLConnectionString is the connection uri // for the postgresql database which will be used if // the HelmDriver is set to SQL SQLConnectionString string // Namespace in which the resources are supposed to // be deployed // // Defaults to "default" Namespace string // CreateNamespace creates namespace if it doesn't exists // // Defaults to false CreateNamespace bool // OverrideValues are used during installation // to override the the values present in Values.yaml // it is equivalent to --set or --set-file helm flag OverrideValues map[string]interface{} // Delete indicates if the requested action is a delete // action // // Defaults to false Delete bool }
ApplyHelmChartConfig defines the options that ApplyHelmChart can take
type ApplyOptions ¶
type Client ¶ added in v0.1.26
type Client struct { RestConfig rest.Config `json:"restconfig,omitempty"` KubeClient *kubernetes.Clientset `json:"kubeclient,omitempty"` DynamicKubeClient dynamic.Interface `json:"dynamic_kubeclient,omitempty"` }
func (*Client) ApplyHelmChart ¶ added in v0.1.31
func (client *Client) ApplyHelmChart(cfg ApplyHelmChartConfig) error
ApplyHelmChart takes in the url for the helm chart and applies that chart as per the ApplyHelmChartOptions
The Helm library requires the environment variable KUBECONFIG to be set.
ApplyHelmChart supports:
- Installation and uninstallation of charts.
- All storage drivers.
- Chart location as a url as well as in form of repository (url) and chart name.
- Override values (equivalent to --set, --set-file, --values in helm).
Examples:
Install Traefik Mesh using URL:
err = client.ApplyHelmChart(k8s.ApplyHelmChartConfig{ Namespace: "traefik-mesh", CreateNamespace: true, URL: "https://helm.traefik.io/mesh/traefik-mesh-3.0.6.tgz", })
Install Traefik Mesh using repository:
err = cl.ApplyHelmChart(k8s.ApplyHelmChartConfig{ ChartLocation: k8s.HelmChartLocation{ Repository: "https://helm.traefik.io/mesh", Chart: "traefik-mesh", }, Namespace: "traefik-mesh", CreateNamespace: true, })
Install Consul Service Mesh overriding values using a values file (equivalent to -f/--values in helm):
p := getter.All(cli.New()) valueOpts := &values.Options{} if valuesFile, ok := operation.AdditionalProperties[config.HelmChartValuesFileKey]; ok { valueOpts.ValueFiles = []string{path.Join("consul", "config_templates", valuesFile)} } vals, err := valueOpts.MergeValues(p) err = kubeClient.ApplyHelmChart(mesherykube.ApplyHelmChartConfig{ Namespace: request.Namespace, CreateNamespace: true, Delete: request.IsDeleteOperation, ChartLocation: mesherykube.HelmChartLocation{ Repository: operation.AdditionalProperties[config.HelmChartRepositoryKey], Chart: operation.AdditionalProperties[config.HelmChartChartKey], Version: operation.AdditionalProperties[config.HelmChartVersionKey], }, OverrideValues: vals, })
func (*Client) ApplyManifest ¶ added in v0.1.26
func (client *Client) ApplyManifest(contents []byte, recvOptions ApplyOptions) error
ApplyManifest applies, updates or deletes resources as specified in ApplyOptions. The namespace specified in ApplyOptions is used, if no namespace is specified then the namespace from manifest is used. If the the namespace does not exists, it will be created.
type HelmChartLocation ¶ added in v0.1.31
type HelmChartLocation struct { // Repository is the url of the helm repository // // Defaults to https://charts.helm.sh/stable Repository string // Chart is the name of the chart that is supposed // to be installed. This chart must me present in the // https://REPOSITORY/index.yaml Chart string // Version is the chart version. This version // must be present in the https://REPOSITORY/index.yaml // // Defaults to Latest Version string }
HelmChartLocation describes the structure for defining the location for helm chart
type HelmDriver ¶ added in v0.1.31
type HelmDriver string
HelmDriver is the type for helm drivers
const ( // ConfigMap HelmDriver can be used to instruct // helm to use configmaps as backend ConfigMap HelmDriver = "configmap" // Secret HelmDriver can be used to instruct // helm to use secrets as backend Secret HelmDriver = "secret" // SQL HelmDriver can be used to instruct // helm to use sql as backend // // This should be used when release information // is expected to be greater than 1MB SQL HelmDriver = "sql" )
type ServiceOptions ¶ added in v0.2.3
type ServiceOptions struct { Name string // Name of the kubernetes service Namespace string // Namespace of the kubernetes service PortSelector string // To specify the name of the kubernetes service port APIServerURL string // Kubernetes api-server URL (Used in-case of minikube) WorkerNodeIP string // Kubernetes worker node IP address (Any), in case of a kubeadm based cluster orchestration Mock *utils.MockOptions }
ServiceOptions give control of which service to discover and which port to discover.