Documentation
¶
Overview ¶
Package kubernetes runs services on a Kubernetes cluster through kubectl, so it uses whatever auth the user's kubeconfig has. It never falls back to the current context: the environment names it.
Index ¶
- func New(env core.Env, c *spec.Component) (any, error)
- func TextTable(s string) core.Table
- type HelmSection
- type Options
- type Runtime
- func (r *Runtime) Actions() []core.Action
- func (r *Runtime) ApplyManifests(ctx context.Context, objs []*manifest.Object) error
- func (r *Runtime) Bridge(ctx context.Context, s *spec.Service, ports map[int]string) error
- func (r *Runtime) Close() error
- func (r *Runtime) Deploy(ctx context.Context, s *spec.Service, rel core.Release) error
- func (r *Runtime) Discover(ctx context.Context) ([]core.Workload, error)
- func (r *Runtime) Exec(ctx context.Context, s *spec.Service, o core.ExecOptions) error
- func (r *Runtime) Forward(ctx context.Context, t core.Target) (string, error)
- func (r *Runtime) Hosts(ctx context.Context) ([]core.Host, error)
- func (r *Runtime) Init() error
- func (r *Runtime) InjectedEnv(s *spec.Service) map[string]bool
- func (r *Runtime) KubectlArgs() []string
- func (r *Runtime) LiveEnv(ctx context.Context, s *spec.Service) (map[string]string, error)
- func (r *Runtime) LiveObject(ctx context.Context, kind, name string) ([]byte, error)
- func (r *Runtime) LiveObjects(ctx context.Context) ([]byte, error)
- func (r *Runtime) LoadState(ctx context.Context) (map[string]string, error)
- func (r *Runtime) Logs(ctx context.Context, s *spec.Service, o core.LogOptions) (<-chan core.LogLine, error)
- func (r *Runtime) Objects(s *spec.Service) ([]*manifest.Object, *manifest.Object, error)
- func (r *Runtime) QueryLanguage() string
- func (r *Runtime) Registry() string
- func (r *Runtime) Render(ctx context.Context, s *spec.Service, rel core.Release) ([]byte, error)
- func (r *Runtime) Resources(ctx context.Context, s *spec.Service) ([]core.Resources, error)
- func (r *Runtime) Restart(ctx context.Context, s *spec.Service) error
- func (r *Runtime) RunQuery(ctx context.Context, q string) (core.Table, error)
- func (r *Runtime) SaveState(ctx context.Context, m map[string]string) error
- func (r *Runtime) Scale(ctx context.Context, s *spec.Service, n int) error
- func (r *Runtime) SetAutoscale(ctx context.Context, s *spec.Service, b core.Bounds) error
- func (r *Runtime) SetEnv(env core.Env)
- func (r *Runtime) SetResources(ctx context.Context, s *spec.Service, res core.Resources) error
- func (r *Runtime) Shell(ctx context.Context, host string, command []string) (*exec.Cmd, error)
- func (r *Runtime) Start(ctx context.Context, s *spec.Service) error
- func (r *Runtime) Status(ctx context.Context, s *spec.Service) (core.Status, error)
- func (r *Runtime) StatusAll(ctx context.Context, svcs []*spec.Service) ([]core.Status, error)
- func (r *Runtime) Stop(ctx context.Context, s *spec.Service) error
- type Section
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HelmSection ¶
type HelmSection struct {
Chart string `yaml:"chart"` // a path, repo/name or oci:// reference
Version string `yaml:"version"`
Release string `yaml:"release"` // default: the service name
Values []string `yaml:"values"` // values files, relative to the project
// Set are --set values; $TAG, $NAMESPACE and the environment's manifest vars are filled in.
Set map[string]string `yaml:"set"`
// Where rig puts what it builds and scales, e.g. image.repository, image.tag, replicaCount.
ImageKey string `yaml:"image_key"`
TagKey string `yaml:"tag_key"`
ReplicasKey string `yaml:"replicas_key"`
}
HelmSection deploys a service with a Helm chart instead of manifests (`helm:` on the service). Status, logs, scale and the rest still work through k8s.workload, which names what the chart creates (charts often call it <release>-<chart>).
type Options ¶
type Options struct {
Context string `yaml:"context"`
// Server finds the context by its cluster's API address when machines name it differently
Server string `yaml:"server"`
Namespace string `yaml:"namespace"`
Registry string `yaml:"registry"`
// PullRegistry is the registry as the cluster's nodes name it, when that differs from where
// builds push (registry.local vs registry.local:80, say).
PullRegistry string `yaml:"pull_registry"`
Manifests []string `yaml:"manifests"`
Vars map[string]string `yaml:"vars"`
Env map[string]string `yaml:"env"`
CreateNamespace bool `yaml:"create_namespace"`
StateConfigMap string `yaml:"state_configmap"`
// Debug gives service containers SYS_PTRACE, so dlv in the image (the go builder's debug) can attach.
Debug bool `yaml:"debug"`
NodeShellImage string `yaml:"node_shell_image"`
}
type Runtime ¶
type Runtime struct {
Opt Options
// HostIP is the address pods use to reach this machine; set by runtimes that know it (kind).
HostIP func(ctx context.Context) (string, error)
// contains filtered or unexported fields
}
func (*Runtime) ApplyManifests ¶
ApplyManifests applies objects as they are written, with the environment's manifest variables filled in: what rig would deploy, for objects no service owns (or before one does).
func (*Runtime) Bridge ¶
Bridge creates a selector-less Service named after s whose Endpoints are the given addresses, so pods reach a service running on the host (or in docker) by its usual name.
func (*Runtime) InjectedEnv ¶
InjectedEnv names the env vars a deploy of s adds from rig.yaml, which a manifest synced back from the cluster should not take in.
func (*Runtime) KubectlArgs ¶
KubectlArgs point kubectl at this environment's cluster and namespace.
func (*Runtime) LiveEnv ¶
LiveEnv is the first container's env on the cluster; values from secrets and config maps show where they come from.
func (*Runtime) LiveObject ¶
LiveObject is one object of the namespace as JSON (`kubectl get -o json`).
func (*Runtime) LiveObjects ¶
LiveObjects are the namespace's objects as YAML documents, stripped of what the cluster adds (status, managed fields, defaults no one set); objects another object owns are left out.
func (*Runtime) Objects ¶
Objects returns what a deploy of s applies: its own manifest files, or the workload found in the environment's manifest folders with everything bundled with it, or nil when it has neither.
func (*Runtime) QueryLanguage ¶
func (*Runtime) SetAutoscale ¶
SetAutoscale moves the bounds of the HPA that scales s, or creates one (named after the workload) scaling on b's CPU and memory targets when there is none.
func (*Runtime) SetResources ¶
SetResources runs `kubectl set resources` on one container; empty values stay as they are.