user890234
user890234

Reputation: 995

Pod manifest into Deployment Manifest

In Kubernetes, What is the easy way to convert a running pod manifest into a Deployment with x number of replicas?

i tried by fetching manifest

k get po xyz -o yaml>po1.yaml

then editing the yaml and matching with a deployment manifest, but seems it was not easy. I kept on getting errors, while converting.

Upvotes: 0

Views: 2056

Answers (1)

XciD
XciD

Reputation: 2617

You can't do dit automatically, they is a few fields that are computed on the submit of the pod.

But you can play a little with yq to extract the spec of the pod:

k get pod/xyz -o yaml | yq .spec -y > pod-spec.yml

Then you just have to add it to a deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: deployment
  name: deployment
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: deployment
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: deployment
    spec: <here>

Don't forget to remove from the pod spec:

  • volumeMounts and volume of the service account
  • nodeName

There is also a lot of default fields that you can remove.

Upvotes: 4

Related Questions