Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add cluster stacks plugin #800

Open
wants to merge 16 commits into
base: 710-feature-request-enable-compliance-tests-to-use-plugins-for-cluster-provisioning
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
node_modules
Tests/kaas/results/
*.tar.gz
.pytest-kind/
78 changes: 71 additions & 7 deletions Tests/kaas/plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

## Development environment

### requirements
### Requirements

* [docker](https://docs.docker.com/engine/install/)
* [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)
* [sonobuoy](https://sonobuoy.io/docs/v0.57.1/#installation)

### setup for development
### Setup for Development

1. Generate python 3.10 env
1. **Generate python 3.10 env**

```bash
sudo apt-get install python3.10-dev
Expand All @@ -23,17 +23,81 @@

```

2. Install dependencies:
2. **Install dependencies:**

```bash
(venv) pip install pip-tools
(venv) pip-compile requirements.in
(venv) pip-sync requirements.txt
```

3. Set environment variables and launch the process:
3. **Create a Cluster**

To create a cluster, run:

```bash
(venv) export CLUSTER_PROVIDER="kind"
(venv) python run.py
(venv) python run_plugin.py create <plugin-name> ../clusterspec.yaml
```

## Setting up and running the cluster-stacks plugin

This section covers how to configure and run the `cluster-stacks` plugin to provision Kubernetes clusters and perform conformance tests.

### Requirements for cluster-stacks plugin

In addition to the core requirements, ensure the following are set up:

* An **OpenStack** environment configured and accessible.
* A `clouds.yaml` file defining OpenStack credentials and endpoints.
* An installing the envsubst via this command:
```bash
GOBIN=/tmp go install github.com/drone/envsubst/v2/cmd/envsubst@latest
```

### Environment Variables

Before running the `cluster-stacks` plugin, you need to set up the following environment variable:

- **GIT_ACCESS_TOKEN**: This token is required for Git operations, especially if your repository is private.

To set the `GIT_ACCESS_TOKEN`, run the following command in your terminal:

```bash
export GIT_ACCESS_TOKEN=<your-github-token>
```

### Configuring config file for cluster-stacks plugin

The config file is used to set parameters for creating a Kubernetes cluster with the `cluster-stacks` plugin. This file allows you to specify details related to the cluster-stack, Git integration, and cluster configurations. These optional parameters are grouped below by their category.

#### Cluster-Stack Related Parameters

These parameters configure specific settings for the cluster-stack:

```yaml
cs_name: <cs_name> # Default: "scs"
cs_version: <cs_version> # Default: "v1"
cs_channel: <cs_channel> # Default: "stable"
cs_cloudname: <cs_cloudname> # Default: "openstack"
```

#### Git-Related Parameters

The [Cluster Stack Operator](https://github.com/sovereignCloudStack/cluster-stack-operator/) (CSO) utilizing the [Cluster Stack Provider OpenStack](https://github.com/SovereignCloudStack/cluster-stacks/tree/main/providers/openstack) (CSPO) must be directed to the Cluster Stacks repository housing releases for the OpenStack provider. Modify the following parameters if you wish to redirect CSO and CSPO to an alternative Git repository

```yaml
git_provider: <git_provider> # Default: "github"
git_org_name: <git_org_name> # Default: "SovereignCloudStack"
git_repo_name: <git_repo_name> # Default: "cluster-stacks"
```

#### Cluster Parameters

Set these parameters to customize the configuration for your cluster.

```yaml
cs_pod_cidr: <cs_pod_cidr> # Default: "192.168.0.0/16"
cs_service_cidr: <cs_service_cidr> # Default: "10.96.0.0/12"
cs_external_id: <cs_external_id> # Default: A generated UUID
cs_k8s_patch_version: <cs_k8s_patch_version> # Default: "6"
```
35 changes: 35 additions & 0 deletions Tests/kaas/plugin/cluster.yaml
mbuechse marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Cluster resource template
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: ${CS_CLUSTER_NAME}
namespace: ${CS_NAMESPACE}
labels:
managed-secret: cloud-config
spec:
clusterNetwork:
pods:
cidrBlocks:
- ${CS_POD_CIDR}
serviceDomain: cluster.local
services:
cidrBlocks:
- ${CS_SERVICE_CIDR}
topology:
variables:
- name: controller_flavor
value: "SCS-2V-4-50"
- name: worker_flavor
value: "SCS-2V-4-50"
- name: external_id
value: ${CS_EXTERNAL_ID}
class: ${CS_CLASS_NAME}
controlPlane:
replicas: 1
version: v${CS_K8S_VERSION}.${CS_K8S_PATCH_VERSION}
workers:
machineDeployments:
- class: default-worker
failureDomain: nova
name: default-worker
replicas: 3
30 changes: 30 additions & 0 deletions Tests/kaas/plugin/clusterstack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Cluster-stack and OpenStack cluster-stack release resource templates
apiVersion: clusterstack.x-k8s.io/v1alpha1
kind: ClusterStack
metadata:
name: clusterstack
namespace: ${CS_NAMESPACE}
spec:
provider: openstack
name: ${CS_NAME}
kubernetesVersion: "${CS_K8S_VERSION}"
channel: ${CS_CHANNEL}
autoSubscribe: false
providerRef:
apiVersion: infrastructure.clusterstack.x-k8s.io/v1alpha1
kind: OpenStackClusterStackReleaseTemplate
name: cspotemplate
versions:
- ${CS_VERSION}
---
apiVersion: infrastructure.clusterstack.x-k8s.io/v1alpha1
kind: OpenStackClusterStackReleaseTemplate
metadata:
name: cspotemplate
namespace: ${CS_NAMESPACE}
spec:
template:
spec:
identityRef:
kind: Secret
name: ${CS_SECRETNAME}
3 changes: 2 additions & 1 deletion Tests/kaas/plugin/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ def create_cluster(self, cluster_name, version, kubeconfig_filepath):
"""
raise NotImplementedError

def delete_cluster(self, cluster_name):
def delete_cluster(self, cluster_name, kubeconfig_filepath):
"""
This method is to be called in order to unprovision a cluster
:param: cluster_name:
:param: kubeconfig_filepath:
"""
raise NotImplementedError
Loading