|
1 | 1 | # machine-controller-manager-provider-stackit |
| 2 | + |
| 3 | +[](https://api.reuse.software/info/github.com/aoepeople/machine-controller-manager-provider-stackit) |
| 4 | + |
2 | 5 | [](https://api.reuse.software/info/github.com/aoepeople/machine-controller-manager-provider-stackit) |
3 | 6 |
|
4 | | -Out of tree (controller based) implementation for `STACKIT` as a new provider. |
| 7 | +Out of tree (controller based) implementation for `STACKIT` as a provider for Gardener. |
| 8 | + |
| 9 | +A Machine Controller Manager (MCM) external provider implementation for STACKIT cloud infrastructure. This provider enables Gardener to manage virtual machines on STACKIT using the declarative Kubernetes API. |
| 10 | + |
| 11 | +The provider was built following the [MCM provider development guidelines](https://github.com/gardener/machine-controller-manager/blob/master/docs/development/cp_support_new.md) and bootstrapped from the [sample provider template](https://github.com/gardener/machine-controller-manager-provider-sampleprovider).Following are the basic principles kept in mind while developing the external plugin. |
| 12 | + |
| 13 | +## Project Structure |
| 14 | + |
| 15 | +``` |
| 16 | +machine-controller-manager-provider-stackit/ |
| 17 | +├── cmd/ |
| 18 | +│ └── machine-controller/ |
| 19 | +│ └── main.go # Provider entrypoint |
| 20 | +├── pkg/ |
| 21 | +│ ├── provider/ |
| 22 | +│ │ ├── core.go # Core provider implementation |
| 23 | +│ │ ├── provider.go # Driver interface implementation |
| 24 | +│ │ ├── stackit_client.go # STACKIT API client |
| 25 | +│ │ ├── apis/ |
| 26 | +│ │ │ ├── provider_spec.go # ProviderSpec CRD definitions |
| 27 | +│ │ │ └── validation/ # Field validation logic |
| 28 | +│ │ └── *_test.go # Unit tests |
| 29 | +│ └── spi/ |
| 30 | +│ └── spi.go # Service provider interface |
| 31 | +├── test/ |
| 32 | +│ └── e2e/ # End-to-end integration tests |
| 33 | +├── samples/ # Example manifests |
| 34 | +├── kubernetes/ # Deployment manifests |
| 35 | +└── vendor/ # Go module dependencies |
| 36 | +``` |
| 37 | + |
| 38 | +## Getting Started |
| 39 | + |
| 40 | +### Prerequisites |
| 41 | + |
| 42 | +- **[Hermit](https://cashapp.github.io/hermit/)** - Environment manager that provides isolated, reproducible tooling |
| 43 | +- Access to a STACKIT project with API credentials |
| 44 | +- Docker (for building container images) |
| 45 | + |
| 46 | +### Tool Management |
| 47 | + |
| 48 | +This project uses **Hermit** for reproducible development environments and **just** as the command runner. |
| 49 | + |
| 50 | +**Hermit** automatically manages tool versions (Go, kubectl, kind, ginkgo, etc.) defined in `bin/hermit.hcl`. When you activate the Hermit environment, all required tools are available without manual installation: |
| 51 | + |
| 52 | +```sh |
| 53 | +# Activate hermit environment (tools auto-install on first use) |
| 54 | +. ./bin/activate-hermit |
| 55 | + |
| 56 | +# Or install hermit shell hooks for automatic activation |
| 57 | +hermit shell-hooks |
| 58 | +``` |
| 59 | + |
| 60 | +**just** is the task runner (defined in `justfile`). It provides a cleaner syntax than Make and better task organization: |
| 61 | + |
| 62 | +```sh |
| 63 | +# List all available commands |
| 64 | +just --list |
| 65 | + |
| 66 | +# Or just run 'just' with no arguments |
| 67 | +just |
| 68 | +``` |
| 69 | + |
| 70 | +### Quick Start |
| 71 | + |
| 72 | +```sh |
| 73 | +just build # Build the provider binary |
| 74 | +just test # Run unit tests |
| 75 | +just test-e2e # Run end-to-end tests |
| 76 | +just dev # Complete local dev setup (cluster + deployment) |
| 77 | +just start # Run provider locally for debugging |
| 78 | +just docker-build # Build container image |
| 79 | +``` |
| 80 | + |
| 81 | +**NOTE:** Run `just --list` for more information on all available commands. |
| 82 | + |
| 83 | +### Deployment |
| 84 | + |
| 85 | +See the [samples/](./samples/) directory for example manifests including: |
| 86 | +- `secret.yaml` - STACKIT credentials configuration |
| 87 | +- `machine-class.yaml` - MachineClass definition |
| 88 | +- `machine.yaml` - Individual Machine example |
| 89 | +- `machine-deployment.yaml` - MachineDeployment for scaled workloads |
| 90 | +- `deployment.yaml` - Provider controller deployment |
| 91 | + |
| 92 | +Deploy using standard kubectl commands: |
| 93 | + |
| 94 | +```sh |
| 95 | +kubectl apply -f samples/secret.yaml |
| 96 | +kubectl apply -f samples/machine-class.yaml |
| 97 | +kubectl apply -f samples/machine.yaml |
| 98 | +``` |
| 99 | + |
| 100 | +## Configuration Reference |
| 101 | + |
| 102 | +### ProviderSpec Fields |
| 103 | + |
| 104 | +| Field | Type | Required | Description | |
| 105 | +|-------|------|----------|-------------| |
| 106 | +| `machineType` | string | Yes | STACKIT server type (e.g., "c1.2", "m1.4") | |
| 107 | +| `imageId` | string | Yes | UUID of the OS image | |
| 108 | +| `labels` | map[string]string | No | Labels for server identification | |
| 109 | +| `networking` | NetworkingSpec | No | Network configuration (NetworkID or NICIDs) | |
| 110 | +| `securityGroups` | []string | No | Security group names | |
| 111 | +| `userData` | string | No | Cloud-init user data (overrides Secret.userData) | |
| 112 | +| `bootVolume` | BootVolumeSpec | No | Boot disk configuration | |
| 113 | +| `volumes` | []string | No | UUIDs of additional volumes to attach | |
| 114 | +| `keypairName` | string | No | SSH keypair name | |
| 115 | +| `availabilityZone` | string | No | Availability zone (e.g., "eu01-1") | |
| 116 | +| `affinityGroup` | string | No | UUID of affinity group | |
| 117 | +| `serviceAccountMails` | []string | No | Service account email addresses (max 1) | |
| 118 | +| `agent` | AgentSpec | No | STACKIT agent configuration | |
| 119 | +| `metadata` | map[string]interface{} | No | Custom metadata key-value pairs | |
| 120 | + |
| 121 | +## Contributing |
| 122 | + |
| 123 | +Contributions are welcome! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines. |
| 124 | + |
| 125 | +### Development Workflow |
| 126 | + |
| 127 | +1. Fork the repository |
| 128 | +2. Create a feature branch: `git checkout -b feature/my-feature` |
| 129 | +3. Make changes and add tests |
| 130 | +4. Run verification: `just test && just golang::lint` |
| 131 | +5. Commit with meaningful messages |
| 132 | +6. Push and create a Pull Request |
| 133 | + |
| 134 | +### Local Testing |
| 135 | + |
| 136 | +Use the local development environment for rapid iteration: |
| 137 | + |
| 138 | +```sh |
| 139 | +# Set up dev environment |
| 140 | +just dev |
| 141 | + |
| 142 | +# Or run provider locally for debugging |
| 143 | +just start |
| 144 | +``` |
| 145 | + |
| 146 | +## References |
| 147 | + |
| 148 | +- [Machine Controller Manager](https://github.com/gardener/machine-controller-manager) - Core MCM project |
| 149 | +- [MCM Provider Development Guide](https://github.com/gardener/machine-controller-manager/blob/master/docs/development/cp_support_new.md) - Guidelines followed to build this provider |
| 150 | +- [MCM Sample Provider](https://github.com/gardener/machine-controller-manager-provider-sampleprovider) - Original template used as starting point |
| 151 | +- [MCM Driver Interface](https://github.com/gardener/machine-controller-manager/blob/master/pkg/util/provider/driver/driver.go) - Provider contract interface |
| 152 | +- [STACKIT Documentation](https://docs.stackit.cloud/) - STACKIT cloud platform documentation |
| 153 | + |
| 154 | +## License |
| 155 | + |
| 156 | +Copyright 2024 SAP SE or an SAP affiliate company and Gardener contributors. |
5 | 157 |
|
6 | | -## About |
7 | | -- This is a sample repository that provides the blueprint required to implement a new (hyperscale) provider. We call the new provider as `STACKIT` for our ease. |
8 | | -- Each provider implements the interface defined at [MCM OOT driver](https://github.com/gardener/machine-controller-manager/blob/master/pkg/util/provider/driver/driver.go). |
| 158 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 159 | +you may not use this file except in compliance with the License. |
| 160 | +You may obtain a copy of the License at |
9 | 161 |
|
10 | | -## Fundamental Design Principles: |
11 | | -Following are the basic principles kept in mind while developing the external plugin. |
12 | | -* Communication between this Machine Controller (MC) and Machine Controller Manager (MCM) is achieved using the Kubernetes native declarative approach. |
13 | | -* Machine Controller (MC) behaves as the controller used to interact with the cloud provider and manage the VMs corresponding to the machine objects. |
14 | | -* Machine Controller Manager (MCM) deals with higher level objects such as machine-set and machine-deployment objects. |
| 162 | + http://www.apache.org/licenses/LICENSE-2.0 |
15 | 163 |
|
16 | | -## Support for a new provider |
17 | | -- Steps to be followed while implementing a new provider are mentioned [here](https://github.com/gardener/machine-controller-manager/blob/master/docs/development/cp_support_new.md) |
| 164 | +Unless required by applicable law or agreed to in writing, software |
| 165 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 166 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 167 | +See the License for the specific language governing permissions and |
| 168 | +limitations under the License. |
0 commit comments