How to Disable Pycharm from Introducing Leading Space in Kubernetes Manifest files?

Kubernetes documentation allows having multiple manifests in the same ```yaml``` file. So I am trying this one in pycharm. 

 

apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis
  labels:
    app: redis # This determines the routing from service.spec.selector.app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      labels:
        app: redis
    spec:
      containers:
        - name: redis
          image: redis:alpine
          ports:
            - containerPort: 6379 # Standard port of redis
#  The following line is meant to separate the Deployment and Service. This line is introducing a leading space 

---
apiVersion: v1
kind: Service
metadata:
  name: redis # This is the name of the service that must be queried to get the public IP.
spec:
  selector:
    app: redis # This has to be the same as the deployment.metadata.labels.app
  ports:
    - protocol: TCP
      port: 6379 # This is the host port
      targetPort: 6379 # This is the container port 
  type: ClusterIP 
 

However, at the separator line, pycharm is introducing a leading space as soon as I save the file. It also shows an error like ```Invalid child element in a block mapping```. 

The leading space results in kubectl failing to parse the yaml for deployment. How to resolve it? 

 

0

Please sign in to leave a comment.