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.
--file
JSON
/YAML
file containing Kubernetes objects. Use --file -
to enable input from stdin.--protocol
http
. [choices: http
, http2
, grpc
, tcp
].The cpln convert command has specific conversion capabilities, detailed as follows:
To demonstrate the convert
command, create a k8s.yaml
file with the following content:
copyapiVersion: apps/v1kind: Deploymentmetadata:name: example-deploymentlabels:app: nginxspec:replicas: 3selector:matchLabels:app: nginxtemplate:metadata:labels:app: nginxspec:containers:- name: nginximage: nginx:latestports:- containerPort: 80
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.
copycpln convert --file k8s.yaml
copykind: workloadname: example-deploymentspec:containers:- name: nginximage: 'nginx:latest'env: []ports:- number: 80protocol: httpargs: []defaultOptions:suspend: falsecapacityAI: falseautoscaling:minScale: 3maxScale: 3type: serverless
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.
copycpln convert --file k8s.yaml --protocol tcp
copykind: workloadname: example-deploymentspec:containers:- name: nginximage: 'nginx:latest'env: []ports:- number: 80protocol: tcpargs: []defaultOptions:suspend: falsecapacityAI: falseautoscaling:minScale: 3maxScale: 3type: serverless
Use the cpln apply command to convert and apply.
copycpln 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 -
To revert the apply, use the following command.
copycpln delete --file k8s.yaml --k8s true