I want to add and remove specific key value pair into kubernetes yamls
For eg:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: null
    version: latest
  name: null
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: null
      version: latest
  template:
    metadata:
      labels:
        app: null
        version: latest
    spec:
      containers:
      - image: aude-service
        name: aude-api
        ports:
        - containerPort: 3003
          hostPort: 3003
          protocol: TCP
Contents to be removed in spec after selector:
hostPort: 3003
protocol: TCP
Contents to be added:
strategy:
  type: RollingUpdate 
  rollingUpdate:
    maxUnavailable: 25% 
It would be of great help, if anyone suggest solution
So, I tried using bash to remove hostport key but it didn't work
awk '/^[[:alpha:]]+:/ {level1=$0; next} level1 ~ "hostPort" && /aaa/ {next} 1' aude-convert.yml
 
     
    