Skip to content

Commit

Permalink
Merge branch 'main' into godaddy
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobdotcosta authored Aug 10, 2023
2 parents 5c8f598 + a48b879 commit ccd09d0
Show file tree
Hide file tree
Showing 4 changed files with 794 additions and 197 deletions.
3 changes: 1 addition & 2 deletions ansible/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ installation for version `1.17` would require adding a new group as child of the
k8s_dashboard_version: v3.1.2
coreos_flannel_sha_commit: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
----

======
====
Expand Down Expand Up @@ -304,7 +303,7 @@ If a host has already been created, it can be imported within the inventory usin
$ ansible-playbook ansible/playbook/passstore_controller_inventory.yml -e vm_name=<VM_NAME> -e pass_provider=hetzner
----

where `<VM_NAME>` corresponds to the host key created under `hetzner`.
...where `<VM_NAME>` corresponds to the host key created under `hetzner`.

[NOTE]
====
Expand Down
193 changes: 165 additions & 28 deletions kind/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,26 @@ cluster with the following default features:
* Launch a container registry using the specified port `e.g. localhost:5000`,
* Set up an Ingress controller to route the external traffic to the cluster.

For that purpose, a bash script has been developed: `./kind.sh`, which can also be used with the command:
For that purpose, several bash scripts have been developed.

`curl -s -L "https://raw.githubusercontent.com/snowdrop/k8s-infra/main/kind/kind.sh" | bash -s ...`
[NOTE]
====
These scripts can also be used directly from the https://github.com/snowdrop/k8s-infra/[snowdrop/k8s-infra GitHub repository] using `curl`.
Example: `curl -s -L "https://raw.githubusercontent.com/snowdrop/k8s-infra/main/kind/kind.sh" | bash -s ...`
`kind.sh` can be replaced by any of the other scripts included in this document.
====

and will let to create or delete a cluster using the https://kind.sigs.k8s.io/[kind] tool.
=== Kind Cluster

The docker registry is started as a `container`, its network shared with the host and can be deployed using the mode:
To create or delete a cluster using the https://kind.sigs.k8s.io/[kind] use the https://github.com/snowdrop/k8s-infra/blob/main/kind/kind.sh[`kind.sh`] script.

=== Container Registry

To create or delete a container registry use the https://github.com/snowdrop/k8s-infra/blob/main/kind/kind.sh[`registry.sh`] script.

The container registry is started as a `container`, its network shared with the host and can be deployed using the mode:

* Unsecure: plain HTTP without user authentication (default)
* Secured: HTTP/TLS using https://httpd.apache.org/docs/current/programs/htpasswd.html[htpasswd] to authenticate the users
Expand All @@ -34,14 +47,16 @@ The docker registry is started as a `container`, its network shared with the hos

To be able to use the bash script, the following tools are required:

* A container runtime:
** Podman: https://podman.io/
* A container runtime (one of):
** Docker: https://docs.docker.com/get-docker/
** Podman: https://podman.io/
* kind: https://github.com/kubernetes-sigs/kind/releases
* kubectl: https://kubernetes.io/docs/tasks/tools/
* helm: https://helm.sh/
* jq: https://stedolan.github.io/jq/download/ (optional)
* openssl (optional)
* jq: https://stedolan.github.io/jq/download/
** Used for validating the environment
* openssl:
** _optional_, unless a secure container registry is used

== Usage

Expand Down Expand Up @@ -118,41 +133,97 @@ Choices:

== Install

Creating a kubernetes cluster is as simple as executing the following command.
This script allows creating both a kind cluster with associated ingress controller and a container registry in separate commands.

.kind deploy statement
=== Container Registry

The first (optional) step is creating a container registry.

.Container Registry creation most relevant options
[%header,cols="2,4"]
|===
| parameter | Description

| `--registry-name`

[.fuchsia]#string#
a| Name to be given to the registry.

Default: kind-registry

| `--registry-password`

[.fuchsia]#string#
a| Registry user password.

Default: `snowdrop`

| `--registry-port`

[.fuchsia]#string#
a| Port to be assigned to the Container Registry.

Default: 5000

| `--registry-user`

[.fuchsia]#string#
a| Registry user.

Default: `admin`
|===

[]
====
.Container registry creation statement
[source,bash]
----
curl -s -L "https://raw.githubusercontent.com/snowdrop/k8s-infra/main/kind/kind.sh" | bash -s install --cluster-name snowdrop --provider podman --port-map "30000:30000,31000:31000"
curl -s -L "https://raw.githubusercontent.com/snowdrop/k8s-infra/main/kind/registry.sh" | bash -s install --registry-name kind-registry.local
----
=== Post deployment steps

==== Allow using an insecure container registry
====

*Using Podman*
=== Kind Cluster

Check the link:https://podman.io/getting-started/installation.html[Podman installation]
document.
Creating a kubernetes cluster is as simple as executing the following command.

.Instructions for Podman
[%collapsible]
[]
====
Add the `kind-registry.conf` file to the `/etc/containers/registries.conf.d/` folder having the following contents.
.Allow using the newly created insecure registry
[source]
.kind deploy statement
[source,bash]
----
[[registry]]
location = "localhost:5000"
insecure = true
curl -s -L "https://raw.githubusercontent.com/snowdrop/k8s-infra/main/kind/kind.sh" | bash -s install --cluster-name snowdrop --port-map "30000:30000,31000:31000" --registry-name kind-registry.local
----
====

.kind cluster creation most relevant options
[%header,cols="2,4"]
|===
| parameter | Description

| `--registry-name`

[.fuchsia]#string#
a| Name of the registry to use.

Default: kind-registry

| `--registry-port`

[.fuchsia]#string#
a| Port to be assigned to the Container Registry.

Default: 5000
|===

=== Post deployment steps

==== Allow using an insecure container registry

*Using Docker*

Check the link:https://docs.docker.com/registry/insecure/[Test an insecure registry
]
Check the link:https://docs.docker.com/registry/insecure/[Test an insecure registry]
Docker document.

.Instructions for Docker
Expand All @@ -169,8 +240,29 @@ Add the following contents to the `/etc/docker/daemon.json` file.
====

*Using Podman*

Check the link:https://podman.io/getting-started/installation.html[Podman installation]
document.

.Instructions for Podman
[%collapsible]
====
Add the `kind-registry.conf` file to the `/etc/containers/registries.conf.d/` folder having the following contents.
.Allow using the newly created insecure registry
[source]
----
[[registry]]
location = "localhost:5000"
insecure = true
----
====

== Remove

=== Kind Cluster

To undeploying a previousy deployed kind cluster use the `remove` action on the kind deploy script.

.kind undeploy statement
Expand All @@ -179,6 +271,15 @@ To undeploying a previousy deployed kind cluster use the `remove` action on the
curl -s -L "https://raw.githubusercontent.com/snowdrop/k8s-infra/main/kind/kind.sh" | bash -s remove --cluster-name snowdrop
----

=== Container Registry

.container registry removal statement
[source,bash]
----
curl -s -L "https://raw.githubusercontent.com/snowdrop/k8s-infra/main/kind/registry.sh" | bash -s remove --registry-name kind-registry.local
----


== Secured docker registry

To deploy a local secured (using htpasswd) docker registry use the `--secure-registry` parameter.
Expand Down Expand Up @@ -274,3 +375,39 @@ https://github.com/kubernetes-sigs/kind/releases[supported images]. The
list of the `kind - kubernetes` images and their version (1.14.x,
1.15.y,…) can be consulted
https://registry.hub.docker.com/v1/repositories/kindest/node/tags[here]

== Multiple Clusters

The kind bash script now supports deploying multiple cluster. Simply
execute the script passing as para meter a new cluster name and

.Get list of clusters from kubeconfig
[source,bash]
----
curl -s -L "https://raw.githubusercontent.com/snowdrop/k8s-infra/main/kind/kind.sh" | bash -s install-cluster --cluster-name snowdrop2 --registry-name kind-registry.local --ingress-ports '10080:10443'
----

[WARNING]
====
Check the `--ingress-ports` to make sure there are no conflicts with
the ports of the different ingress controlers of each cluster.
Each set of ports must be happed with the host ports.
====

Check the list of clusters defined in the kube configuration file.

.Get list of clusters from kubeconfig
[source,bash]
----
kubectl config get-clusters
----

As a result the different clusters will be shown.

.Cluster list with multiple clusters
[source,]
----
NAME
snowdrop2
snowdrop
----
Loading

0 comments on commit ccd09d0

Please sign in to comment.