Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
157 changes: 150 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@
The openmcp bootstrapper is a command line tool that is able to set up an openmcp landscape initially and to update existing openmcp landscapes with new versions of the openmcp project.

Supported commands:
* `ocmTransfer`: Transfers the specified OCM component version from the source location to the target location.
* `ocm-transfer`: Transfers the specified OCM component version from the source location to the target location.
* `deploy-flux`: Deploys the FluxCD components to the specified Kubernetes cluster.
* `manage-deployment-repo`: Templates the openMCP git ops templates and applies them to the specified git repository and all kustomized resources to the specified Kubernetes cluster.

### `ocmTransfer`
Supported global flags:
* `--verbosity`: Sets the verbosity level of the logging output. Supported levels are `trace`, `debug`, `info`, `warn`, `error`. Default is `info`.

The `ocmTransfer` command is used to transfer an OCM component version from a source location to a target location.
The `ocmTransfer` requires the following parameters:
### `ocm-transfer`

The `ocm-transfer` command is used to transfer an OCM component version from a source location to a target location.
The `ocm-transfer` requires the following parameters:
* `source`: The source location of the OCM component version to be transferred.
* `target`: The target location where the OCM component version should be transferred to.

Optional parameters:
* `--config`: Path to the OCM configuration file.
* `--ocm-config`: Path to the OCM configuration file.

```shell
openmcp-bootstrapper ocmTransfer <source-location> <target-location> --config <path-to-ocm-config>
Expand All @@ -31,11 +36,149 @@ ocm --config <path-to-ocm-config> transfer componentversion --recursive --copy-r

Example:
```shell
openmcp-bootstrapper ocmTransfer ghcr.io/openmcp-project/components//github.com/openmcp-project/openmcp:v0.0.11 ./ctf
openmcp-bootstrapper ocmTransfer ghcr.io/openmcp-project/components//github.com/openmcp-project/openmcp:v0.0.11 ghcr.io/my-github-user
openmcp-bootstrapper ocm-transfer ghcr.io/openmcp-project/components//github.com/openmcp-project/openmcp:v0.0.11 ./ctf
openmcp-bootstrapper ocm-transfer ghcr.io/openmcp-project/components//github.com/openmcp-project/openmcp:v0.0.11 ghcr.io/my-github-user
```

## `deploy-flux`

The `deploy-flux` command is used to deploy the FluxCD components to a Kubernetes cluster.
The `deploy-flux` command requires the following parameters:
* `bootstrapper-config`: Path to the bootstrapper configuration file.

Optional parameters:
* `--kubeconfig`: Path to the kubeconfig file of the target Kubernetes cluster. If not set, the value of the `KUBECONFIG` environment variable will be used. If the `KUBECONFIG` environment variable is not set, the default kubeconfig file located at `$HOME/.kube/config` will be used.
* `--ocm-config`: Path to the OCM configuration file.
* `--git-config`: Path to the git configuration file containing the credentials for accessing the git repository. If not set, no authentication will be configured.

### bootstrapper configuration file

The `deploy-flux` command requires a bootstrapper configuration file in YAML format. The configuration file contains the following sections:
* `component` (required): The OCM component version to be deployed. The location must be in the format `<OCM Registry Location>//<Component Name>:<version>`. For example: `ghcr.io/openmcp-project/components//github.com/openmcp-project/openmcp:v0.0.18`.
* `repository` (required): The git repository where the FluxCD components should be deployed to. The `url` field specifies the URL of the git repository and the `branch` field specifies the branch to be used.
* `environment` (required): The name of the openMCP environment that shall be managed by FluxCD. For example: `dev`, `prod`, `dev-eu10`, etc.

```yaml
component:
location: <OCM Registry Location>//<Component Name>:<version>

repository:
url: <git-repo-url>
branch: <branch-name>

environment:
name: <environment-name>
```

Example:
```shell
openmcp-bootstrapper deploy-flux ./examples/bootstrapper-config.yaml --kubeconfig ~/.kube/config --ocm-config ./examples/ocm-config.yaml --git-config ./examples/git-config.yaml ./examples/bootstrapper-config.yaml
```

## `manage-deployment-repo`

The `manageDeploymentRepo` command is used to template the openMCP git ops templates and apply them to the specified git repository and all kustomized resources to the specified Kubernetes cluster.
The `manageDeploymentRepo` command requires the following parameters:
* `bootstrapper-config`: Path to the bootstrapper configuration file.
* `--git-config`: Path to the git configuration file containing the credentials for accessing the git repository.

Optional parameters:
* `--kubeconfig`: Path to the kubeconfig file of the target Kubernetes cluster. If not set, the value of the `KUBECONFIG` environment variable will be used. If the `KUBECONFIG` environment variable is not set, the default kubeconfig file located at `$HOME/.kube/config` will be used.
* `--ocm-config`: Path to the OCM configuration file.
* `--extra-manifest-dir` (repeatable): Path to an extra manifest directory that should be added to the kustomization. This can be used to add custom resources to the deployment.
*


The `manage-deployment-repo` requires a bootstrapper configuration file in YAML format. The configuration file contains the following sections:
* `component` (required): The OCM component version to be deployed. The location must be in the format `<OCM Registry Location>//<Component Name>:<version>`. For example: `gh
* `repository` (required): The git repository where the FluxCD components should be deployed to. The `url` field specifies the URL of the git repository and the `branch` field specifies the branch to be used.
* `environment` (required): The name of the openMCP environment that shall be managed by FluxCD. For example: `dev`, `prod`, `dev-eu10`, etc.
* `imagePullSecrets` (optional): A list of image pull secrets that shall be used for all Kubernetes deployments created by the bootstrapper. The secrets must already exist in the target cluster in the namespace `openmcp-system`.
* `providers` (optional): A list of `cluster-providers`, `service-providers`, and `platform-services` that shall be enabled in the deployment. Each provider can have its own configuration.
* `openmcpOperator` (required): Configuration for the openmcp operator.

```yaml
component:
location: <OCM Registry Location>//<Component Name>:<version>

repository:
url: <git-repo-url>
branch: <branch-name>

environment:
name: <environment-name>

imagePullSecrets:
- <image-pull-secret-name>

providers:
clusterProviders:
- name: kind
config:
extraVolumeMounts:
- mountPath: /var/run/docker.sock
name: docker
extraVolumes:
- name: docker
hostPath:
path: /var/run/host-docker.sock
type: Socket
verbosity: debug
serviceProviders:
- name: landscaper
config:
verbosity: debug

platformServices: []

openmcpOperator:
config:
managedControlPlane:
mcpClusterPurpose: mcp-worker
reconcileMCPEveryXDays: 7
scheduler:
scope: Cluster
purposeMappings:
mcp:
template:
spec:
profile: kind
tenancy: Exclusive
mcp-worker:
template:
spec:
profile: kind
tenancy: Exclusive
platform:
template:
metadata:
labels:
clusters.openmcp.cloud/delete-without-requests: "false"
spec:
profile: kind
tenancy: Shared
onboarding:
template:
metadata:
labels:
clusters.openmcp.cloud/delete-without-requests: "false"
spec:
profile: kind
tenancy: Shared
workload:
tenancyCount: 20
template:
metadata:
namespace: workload-clusters
spec:
profile: kind
tenancy: Shared
```

Example:
```shell
openmcp-bootstrapper manage-deployment-repo --kubeconfig ~/.kube/config --ocm-config ./examples/ocm-config.yaml --git-config ./examples/git-config.yaml --extra-manifest-dir ./my-custom-manifests ./examples/bootstrapper-config.yaml
```

## Requirements and Setup

Expand Down
7 changes: 7 additions & 0 deletions cmd/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package cmd

const (
FlagGitConfig = "git-config"
FlagOcmConfig = "ocm-config"
FlagKubeConfig = "kubeconfig"
)
1 change: 1 addition & 0 deletions cmd/deploy_flux.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var deployFluxCmd = &cobra.Command{
ArgAliases: []string{
"configFile",
},
Example: ` openmcp-bootstrapper deploy-flux "./config.yaml"`,
RunE: func(cmd *cobra.Command, args []string) error {
configFilePath := args[0]

Expand Down
9 changes: 3 additions & 6 deletions cmd/manageDeploymentRepo.go → cmd/manage_deployment_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ import (
)

const (
FlagGitConfig = "git-config"
FlagOcmConfig = "ocm-config"
FlagKubeConfig = "kubeconfig"
FlagExtraManifestDir = "extra-manifest-dir"
)

Expand All @@ -33,16 +30,16 @@ func (w LogWriter) Write(p []byte) (n int, err error) {

// manageDeploymentRepoCmd represents the manageDeploymentRepo command
var manageDeploymentRepoCmd = &cobra.Command{
Use: "manageDeploymentRepo",
Use: "manage-deployment-repo",
Short: "Updates the openMCP deployment specification in the specified Git repository",
Long: `Updates the openMCP deployment specification in the specified Git repository.
The update is based on the specified component version.
openmcp-bootstrapper manageDeploymentRepo <configFile>`,
openmcp-bootstrapper manage-deployment-repo <configFile>`,
Args: cobra.ExactArgs(1),
ArgAliases: []string{
"configFile",
},
Example: ` openmcp-bootstrapper manageDeploymentRepo "./config.yaml"`,
Example: ` openmcp-bootstrapper manage-deployment-repo "./config.yaml"`,
RunE: func(cmd *cobra.Command, args []string) error {
configFilePath := args[0]

Expand Down
8 changes: 4 additions & 4 deletions cmd/ocmTransfer.go → cmd/ocm_transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

// ocmTransferCmd represents the "ocm transfer componentversion" command
var ocmTransferCmd = &cobra.Command{
Use: "ocmTransfer source target",
Use: "ocm-transfer source target",
Short: "Transfer an OCM component from a source to a target location",
Long: `Transfers the specified OCM component version from the source location to the target location.`,
Aliases: []string{
Expand All @@ -23,7 +23,7 @@ var ocmTransferCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
log := log.GetLogger()

log.Debugf("Executing ocmTransfer with source: %s, target: %s", args[0], args[1])
log.Debugf("Executing ocm-transfer with source: %s, target: %s", args[0], args[1])

transferCommands := []string{
"transfer",
Expand All @@ -38,12 +38,12 @@ var ocmTransferCmd = &cobra.Command{
args[1], // target
}

return ocmcli.Execute(cmd.Context(), transferCommands, transferArgs, cmd.Flag("config").Value.String())
return ocmcli.Execute(cmd.Context(), transferCommands, transferArgs, cmd.Flag(FlagOcmConfig).Value.String())
},
}

func init() {
RootCmd.AddCommand(ocmTransferCmd)

ocmTransferCmd.PersistentFlags().StringP("config", "c", "", "ocm configuration file")
ocmTransferCmd.PersistentFlags().String(FlagOcmConfig, "", "ocm configuration file")
}
2 changes: 1 addition & 1 deletion cmd/ocmTransfer_test.go → cmd/ocm_transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestOcmTransfer(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
root := cmd.RootCmd
args := []string{"ocmTransfer"}
args := []string{"ocm-transfer"}
if len(tc.arguments) > 0 {
args = append(args, tc.arguments...)
}
Expand Down