impl

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_internal_impl_kube_proto protoreflect.FileDescriptor

Functions

func BuildAndUploadDockerImage

func BuildAndUploadDockerImage(ctx context.Context, dep *protos.Deployment, buildTag, dockerRepo string, runInDevMode bool) (string, error)

BuildAndUploadDockerImage builds a docker image and uploads it to a remote repo, if one is specified. It returns the docker image tag that should be used in the application containers.

func GenerateKubeDeployment

func GenerateKubeDeployment(image string, dep *protos.Deployment, cfg *KubeConfig) error

GenerateKubeDeployment generates the kubernetes deployment and service information for a given app deployment.

Note that for each application, we generate the following Kubernetes topology:

  • for each replica set that has at least a listener, we generate a deployment whose name is persistent across new app versions rollouts. Note that in general this should only be the replica set that contains the main component. We do this because by default we rely on RollingUpdate as a deployment strategy to rollout new versions of the app. RollingUpdate will update the existing pods for the replica set with the new version one by one, hence the new application version is being deployed. For example, let's assume that we have an app v1 with 2 replica sets main and foo. main is the replica set that contains the public listener, and it has 2 replicas. Next, we deploy the version v2 of the app. v2 will be rolled out as follows:

    [main v1] [main v1] [main v1] [main v2] [main v2] [main v2] | | | | | | v | => v v => | v [foo v1] <---| [foo v1] [foo v2] |-------> [foo v2]

  • for all the replica sets, we create a per app version service so components within an app version can communicate with each other.

  • for all the listeners we create a load balancer or a cluster IP with an unique name that is persistent across new app version rollouts.

  • if Prometheus/Jaeger are enabled, we deploy corresponding services using unique names as well s.t., we don't rollout new instances of Prometheus/Jaeger, when we rollout new versions of the app.

func RunBabysitter

func RunBabysitter(ctx context.Context) error

Types

type KubeConfig

type KubeConfig struct {
	// LocalTag is the build tag for the application container on the local
	// machine.
	//
	// If empty, the tag defaults to "<app_name>:<app_version>", where
	// <app_version> is the unique version id of the application deployment.
	LocalTag string `toml:"local_tag"`

	// Repo is the name of the repository the container should be uploaded to.
	// For example, if set to "docker.io/alanturing/repo", "weaver kube deploy"
	// will build the container locally, tag it with the appropriate Tag, and
	// then push it to "docker.io/alanturing/repo".
	//
	// If empty, the container is built and tagged locally, but is not pushed
	// to a repository.
	//
	// Example repositories are:
	//   - Docker Hub               :  docker.io/USERNAME/REPO_NAME
	//   - Google Artifact Registry :  LOCATION-docker.pkg.dev/PROJECT-ID/REPO_NAME
	//   - GitHub Container Registry: ghcr.io/NAMESPACE
	//
	// Note that the final image tag for the application container will
	// be a concatenation of Repo and Tag, i.e., "Repo/Tag".
	Repo string

	// Namespace is the name of the Kubernetes namespace where the application
	// should be deployed. If not specified, the application will be deployed in
	// the default namespace.
	Namespace string

	// If true, application listeners will use the underlying nodes' network.
	// This behavior is generally discouraged, but it may be useful when running
	// the application in a minikube environment, where using the underlying
	// nodes' network may make it easier to access the listeners directly from
	// the host machine.
	UseHostNetwork bool `toml:"use_host_network"`

	// Options for the application listeners, keyed by listener name.
	// If a listener isn't specified in the map, default options will be used.
	Listeners map[string]*ListenerOptions

	// Observability controls how the deployer will export observability information
	// such as logs, metrics and traces, keyed by service. If no options are
	// specified, the deployer will launch corresponding services for exporting logs,
	// metrics and traces automatically.
	//
	// The key must be one of the following strings:
	// "prometheus_service" - to export metrics to Prometheus [1]
	// "jaeger_service"     - to export traces to Jaeger [2]
	// "loki_service"       - to export logs to Grafana Loki [3]
	// "grafana_service"    - to visualize/manipulate observability information [4]
	//
	// Possible values for each service:
	// 1) do not specify a value at all; leave it empty
	// this is the default behavior; kube deployer will automatically create the
	// observability service for you.
	//
	// 2) "none"
	// kube deployer will not export the corresponding observability information to
	// any service. E.g., prometheus_service = "none" means that the user will not
	// be able to see any metrics at all. This can be useful for testing or
	// benchmarking the performance of your application.
	//
	// 3) "your_observability_service_name"
	// if you already have a running service to collect metrics, traces or logs,
	// then you can simply specify the service name, and your application will
	// automatically export the corresponding information to your service. E.g.,
	// jaeger_service = "jaeger-all-in-one" will enable your running Jaeger
	// "service/jaeger-all-in-one" to capture all the app traces.
	//
	// [1] - https://prometheus.io/
	// [2] - https://www.jaegertracing.io/
	// [3] - https://grafana.com/oss/loki/
	// [4] - https://grafana.com/
	Observability map[string]string
}

KubeConfig stores the configuration information for one execution of a Service Weaver application deployed using the Kube deployer.

type ListenerOptions

type ListenerOptions struct {
	// Is the listener public, i.e., should it receive ingress traffic
	// from the public internet. If false, the listener is configured only
	// for cluster-internal access.
	Public bool

	// If specified, the port inside the container on which the listener
	// is reachable. If zero or not specified, the first available port
	// is used.
	Port int32
}

ListenerOptions stores configuration options for a listener.

type ReplicaSetConfig

type ReplicaSetConfig struct {
	Deployment        *protos.Deployment                     `protobuf:"bytes,1,opt,name=deployment,proto3" json:"deployment,omitempty"`
	ReplicaSet        string                                 `protobuf:"bytes,2,opt,name=replica_set,json=replicaSet,proto3" json:"replica_set,omitempty"`
	ComponentsToStart map[string]*ReplicaSetConfig_Listeners `` /* 202-byte string literal not displayed */
	InternalPort      int32                                  `protobuf:"varint,4,opt,name=internal_port,json=internalPort,proto3" json:"internal_port,omitempty"`
	Namespace         string                                 `protobuf:"bytes,5,opt,name=namespace,proto3" json:"namespace,omitempty"`
	TraceServiceUrl   string                                 `protobuf:"bytes,6,opt,name=trace_service_url,json=traceServiceUrl,proto3" json:"trace_service_url,omitempty"`
	// contains filtered or unexported fields
}

ReplicaSetConfig contains app deployment information that is needed by a babysitter started using the kube deployer to manage a set of components.

func (*ReplicaSetConfig) Descriptor deprecated

func (*ReplicaSetConfig) Descriptor() ([]byte, []int)

Deprecated: Use ReplicaSetConfig.ProtoReflect.Descriptor instead.

func (*ReplicaSetConfig) GetComponentsToStart

func (x *ReplicaSetConfig) GetComponentsToStart() map[string]*ReplicaSetConfig_Listeners

func (*ReplicaSetConfig) GetDeployment

func (x *ReplicaSetConfig) GetDeployment() *protos.Deployment

func (*ReplicaSetConfig) GetInternalPort

func (x *ReplicaSetConfig) GetInternalPort() int32

func (*ReplicaSetConfig) GetNamespace added in v0.19.0

func (x *ReplicaSetConfig) GetNamespace() string

func (*ReplicaSetConfig) GetReplicaSet

func (x *ReplicaSetConfig) GetReplicaSet() string

func (*ReplicaSetConfig) GetTraceServiceUrl added in v0.19.0

func (x *ReplicaSetConfig) GetTraceServiceUrl() string

func (*ReplicaSetConfig) ProtoMessage

func (*ReplicaSetConfig) ProtoMessage()

func (*ReplicaSetConfig) ProtoReflect

func (x *ReplicaSetConfig) ProtoReflect() protoreflect.Message

func (*ReplicaSetConfig) Reset

func (x *ReplicaSetConfig) Reset()

func (*ReplicaSetConfig) String

func (x *ReplicaSetConfig) String() string

type ReplicaSetConfig_Listener

type ReplicaSetConfig_Listener struct {
	Name         string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	ExternalPort int32  `protobuf:"varint,2,opt,name=external_port,json=externalPort,proto3" json:"external_port,omitempty"`
	IsPublic     bool   `protobuf:"varint,3,opt,name=is_public,json=isPublic,proto3" json:"is_public,omitempty"`
	// contains filtered or unexported fields
}

func (*ReplicaSetConfig_Listener) Descriptor deprecated

func (*ReplicaSetConfig_Listener) Descriptor() ([]byte, []int)

Deprecated: Use ReplicaSetConfig_Listener.ProtoReflect.Descriptor instead.

func (*ReplicaSetConfig_Listener) GetExternalPort

func (x *ReplicaSetConfig_Listener) GetExternalPort() int32

func (*ReplicaSetConfig_Listener) GetIsPublic

func (x *ReplicaSetConfig_Listener) GetIsPublic() bool

func (*ReplicaSetConfig_Listener) GetName

func (x *ReplicaSetConfig_Listener) GetName() string

func (*ReplicaSetConfig_Listener) ProtoMessage

func (*ReplicaSetConfig_Listener) ProtoMessage()

func (*ReplicaSetConfig_Listener) ProtoReflect

func (*ReplicaSetConfig_Listener) Reset

func (x *ReplicaSetConfig_Listener) Reset()

func (*ReplicaSetConfig_Listener) String

func (x *ReplicaSetConfig_Listener) String() string

type ReplicaSetConfig_Listeners

type ReplicaSetConfig_Listeners struct {
	Listeners []*ReplicaSetConfig_Listener `protobuf:"bytes,1,rep,name=listeners,proto3" json:"listeners,omitempty"`
	// contains filtered or unexported fields
}

func (*ReplicaSetConfig_Listeners) Descriptor deprecated

func (*ReplicaSetConfig_Listeners) Descriptor() ([]byte, []int)

Deprecated: Use ReplicaSetConfig_Listeners.ProtoReflect.Descriptor instead.

func (*ReplicaSetConfig_Listeners) GetListeners

func (*ReplicaSetConfig_Listeners) ProtoMessage

func (*ReplicaSetConfig_Listeners) ProtoMessage()

func (*ReplicaSetConfig_Listeners) ProtoReflect

func (*ReplicaSetConfig_Listeners) Reset

func (x *ReplicaSetConfig_Listeners) Reset()

func (*ReplicaSetConfig_Listeners) String

func (x *ReplicaSetConfig_Listeners) String() string

Jump to

Keyboard shortcuts

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