Documentation ¶
Overview ¶
Package k3s provides a Gnomock Preset for lightweight kubernetes (k3s). This preset by no means should be used in any kind of deployment, and no other presets are supposed to be deployed in it. The goal of this preset is to allow easier testing of Kubernetes automation tools.
This preset does not use a well-known docker image like most other presets do. Instead, it uses a custom built and adapted image that runs lightweight Kubernetes (k3s) in a docker container: https://github.com/orlangure/k3s-dind.
Please make sure to pick a version here: https://hub.docker.com/repository/docker/orlangure/k3s. At some point k3s version tags should start to appear. If only `latest` tag is available, it comes with k3s v1.18.4.
Keep in mind that k3s runs in a single docker container, meaning it might be limited in memory, CPU and storage. Also remember that this cluster always runs on a single node.
To connect to this cluster, use `Config` function that can be used together with Kubernetes client for Go, or `ConfigBytes` that can be saved as `kubeconfig` file and used by `kubectl`.
Index ¶
Constants ¶
const KubeconfigPort = "kubeconfig"
KubeconfigPort is a port that exposes a single `/kubeconfig` endpoint. It can be used to retrieve a configured kubeconfig file to use to connect to this container using kubectl.
Variables ¶
This section is empty.
Functions ¶
func Config ¶
Config returns `*rest.Config` instance of Kubernetes client-go package. This config can be used to create a new client that will work against k3s cluster running in the provided container.
func ConfigBytes ¶
ConfigBytes returns file contents of kubeconfig file that should be used to connect to the cluster running in the provided container.
Types ¶
type Option ¶
type Option func(*P)
Option is an optional configuration of this Gnomock preset. Use available Options to configure the container
func WithPort ¶
WithPort allows to use a custom port for k3s API access instead of the default one. If no custom port is provided, port 48443 is used instead.
Please make sure that whichever port you choose to use (including the default) is available on the host system. Otherwise this container won't start.
type P ¶
P is a Gnomock Preset implementation of lightweight kubernetes (k3s).
func (*P) Ports ¶
func (p *P) Ports() gnomock.NamedPorts
Ports returns ports that should be used to access this container.