Overview

The cpln convert command is designed to facilitate the migration from Kubernetes environments to Control Plane by converting Kubernetes objects into Control Plane objects.

Typically, this command is utilized alongside the cpln apply command to seamlessly convert and then directly apply the configurations.

Prerequisites

  • CLI installed.

Options

Required

  • --file
    • A JSON/YAML file containing Kubernetes objects. Use --file - to enable input from stdin.

Optional

  • --protocol
    • The port protocol to be assigned to each container within a workload converted from a deployment. Default: http. [choices: http, http2, grpc, tcp].

Limitations

The cpln convert command has specific conversion capabilities, detailed as follows:

  • Workloads Conversion
    • Can convert objects of kind Deployment and CronJob into workloads.
  • Secrets Conversion
    • Capable of converting objects of kind Secret into Control Plane secrets.

Create a K8s file

To demonstrate the convert command, create a k8s.yaml file with the following content:

YAML
apiVersion: apps/v1
kind: Deployment
metadata:
  name: example-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:latest
          ports:
            - containerPort: 80

Convert a K8s file

Basic Convert

The following command will convert the Kubernetes object defined in the above k8s.yaml file into a Control Plane object and output it to the terminal.

cpln convert --file k8s.yaml

Convert With a Specific Protocol

Each Kubernetes object, whether of type Deployment or CronJob, will be transformed into workloads. These workloads will feature containers whose port protocols are aligned with the specification provided in the --protocol option.

cpln convert --file k8s.yaml --protocol tcp

Convert & Apply

Use the cpln apply command to convert and apply.

cpln apply --file k8s.yaml --k8s true

Alternatively, you can pass the conversion result as a stdin to the cpln apply command.

cpln convert --file k8s.yaml | cpln apply --file -

Revert Apply

To revert the apply, use the following command.

cpln delete --file k8s.yaml --k8s true