Mirantis / virtlet

Kubernetes CRI implementation for running VM workloads
Apache License 2.0
739 stars 128 forks source link

Error: "/run/virtlet.sock": rpc error: code = 2 desc = failed to unmarshal cloud-init userdata: error converting YAML to JSON: yaml: line 8: found unknown escape character #881

Closed kishoreakhila closed 5 years ago

kishoreakhila commented 5 years ago

Hi there I'm trying to deploy a pod using helm install with some virtlet annotations. And I have hit a dead-end and was hoping someone could help me here.
here is the deployment.yml.

kind: Deployment
metadata:
  name: {{ include "packetgen.fullname" . }}
  labels:
    app: vFirewall
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: vFirewall
      app.kubernetes.io/name: {{ include "packetgen.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: vFirewall
        app.kubernetes.io/name: {{ include "packetgen.name" . }}
        app.kubernetes.io/instance: {{ .Release.Name }}
      annotations:
        VirtletLibvirtCPUSetting: |
          mode: host-model
        VirtletCloudInitUserData: |
          users:
          - name: admin
            gecos: User
            primary-group: admin
            groups: users
            sudo: ALL=(ALL) NOPASSWD:ALL
            lock_passwd: false
            # the password is "admin"
            passwd: "\$6\$rounds=4096\$QA5OCKHTE41\$jRACivoPMJcOjLRgxl3t.AMfU7LhCFwOWv2z66CQX.TSxBy50JoYtycJXSPr2JceG.8Tq/82QN9QYt3euYEZW/"
          runcmd:
            - export demo_artifacts_version={{ .Values.network.demoArtifactsVersion }}
            - export vfw_private_ip_0={{ .Values.network.vfwPrivateIp0 }}
            - export vsn_private_ip_0={{ .Values.network.vsnPrivateIp0 }}
            - export protected_net_cidr={{ .Values.network.protectedNetCidr }}
            - export dcae_collector_ip={{ .Values.network.dcaeCollectorIp }}
            - export dcae_collector_port={{ .Values.network.dcaeCollectorPort }}
            - export protected_net_gw={{ .Values.network.protectedNetGw }}
            - export protected_private_net_cidr={{ .Values.network.protectedPrivateNetCidr }}
            - wget -O - https://git.onap.org/multicloud/k8s/plain/kud/tests/vFW/packetgen | sudo -E bash
        VirtletRootVolumeSize: 5Gi
        #k8s.v1.cni.cncf.io/networks: '[{"name": {{ .Values.network.ovnMultusNetworkName | quote }}}]'
        #ovnNetwork: '[
            #{ "name": {{ .Values.network.unprotectedNetworkName | quote }}, "ipAddress": {{ .Values.network.vpgPrivateIp0 | quote  }}, "interface": "eth1" , "defaultGateway": "false"},
            #{ "name": {{ .Values.network.onapPrivateNetworkName | quote }}, "ipAddress": {{ .Values.network.vpgPrivateIp1 | quote }}, "interface": "eth2" , "defaultGateway": "false"}
        #]'
        kubernetes.io/target-runtime: virtlet.cloud
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: extraRuntime
                operator: In
                values:
                - virtlet
      containers:
      - name: {{ .Chart.Name }}
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        tty: true
        stdin: true
        ports:
          - containerPort: {{ .Values.service.ports.containerPort }}
        resources:
          limits:
            memory: {{ .Values.resources.limits.memory }}

kubectl describe pod

Events:
  Type     Reason     Age                From                 Message
  ----     ------     ----               ----                 -------
  Normal   Scheduled  90s                default-scheduler    Successfully assigned default/apack-packetgen-5469b6ffd5-26tvj to kubernetes
  Normal   Pulling    26s (x2 over 81s)  kubelet, kubernetes  pulling image "virtlet.cloud/ubuntu/16.04:latest"
  Normal   Pulled     26s                kubelet, kubernetes  Successfully pulled image "virtlet.cloud/ubuntu/16.04:latest"
  Warning  Failed     26s                kubelet, kubernetes  Error: "/run/virtlet.sock": rpc error: code = 2 desc = failed to unmarshal cloud-init userdata: error converting YAML to JSON: yaml: line 8: found unknown escape character
jellonek commented 5 years ago

We are converting yaml definition of cloud init into json one, but json does not allow to have comments - so please remove line containing # the password is "admin". That should fix the issue.

kishoreakhila commented 5 years ago

Hi, @jellonek Thank you for getting back to me. Removing the comment and \ in password fixed it for me.