Skip to content

Yaml language server

Sergey Skorik edited this page Sep 11, 2018 · 8 revisions

Preconditions:

  1. Create workspace from the Node stack with "nodejs-hello-world" project.
  2. Enable Yaml language server in the Installers tab.
  3. Start workspace. Set the YAML schema:
    • Menu Profile -> Preferences;
    • Select Yaml->Add Schema URl button -> type kubernetes.
  4. Create "openshift.yaml".
  5. Create “deployment.yaml” file with content:
apiVersion: v1
kind: DeploymentConfig
metadata:
  annotations:
    openshift.io/generated-by: OpenShiftNewApp
  creationTimestamp: '2018-07-17T11:11:50Z'
  generation: 4
  labels:
    app: che
    template: che
  name: che
  namespace: eclipse-che
  resourceVersion: '9713'
  selfLink: /apis/apps.openshift.io/v1/namespaces/eclipse-che/deploymentconfigs/che
  uid: 33bda3fd-89b2-11e8-be77-8c1645547d72
spec:
  replicas: 1
  revisionHistoryLimit: 2
  selector:
    app: che
  strategy:
    activeDeadlineSeconds: 21600
    recreateParams:
      timeoutSeconds: 600
    resources: {}
    type: Recreate
  template:
    metadata:
      annotations:
        openshift.io/generated-by: OpenShiftNewApp
      creationTimestamp: "null"
      labels:
        app: che
    spec:
      containers:
        - env:
            - name: CHE_CONF
              value: /home/user/che-conf
            - name: CHE_IMAGE_REPO
              value: eclipse/che-server
            - name: CHE_IMAGE_TAG
              value: nightly
            - name: CHE_INFRASTRUCTURE
              value: openshift
            - name: CHE_INFRA_KUBERNETES_MASTER__URL
              value: 'https://172.0.0.1:8443'
            - name: CHE_LOCAL_CONF_DIR
              value: /home/user/che-conf
            - name: CHE_MULTIUSER
              value: 'false'
            - name: CHE_OPENSHIFT_PROJECT
              value: eclipse-che
            - name: OPENSHIFT_KUBE_PING_NAMESPACE
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.namespace
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.namespace
            - name: CHE_HOST
              value: 'che-${NAMESPACE}.172.0.0.1.nip.io'
            - name: CHE_PORT
              value: '8080'
            - name: CHE_API
              value: 'http://che-${NAMESPACE}.172.0.0.1.nip.io/api'
            - name: CHE_WEBSOCKET_ENDPOINT
              value: 'ws://che-${NAMESPACE}.172.0.0.1.nip.io/api/websocket'
            - name: CHE_DEBUG_SERVER
              value: 'false'
            - name: CHE_INFRASTRUCTURE_ACTIVE
              value: openshift
            - name: CHE_INFRA_KUBERNETES_BOOTSTRAPPER_BINARY__URL
              value: >-
                http://che-${NAMESPACE}.172.0.0.1.nip.io/agent-binaries/linux_amd64/bootstrapper/bootstrapper
            - name: CHE_INFRA_KUBERNETES_MACHINE__START__TIMEOUT__MIN
              value: '5'
            - name: CHE_INFRA_KUBERNETES_OAUTH__TOKEN
            - name: CHE_INFRA_KUBERNETES_USERNAME
            - name: CHE_INFRA_KUBERNETES_PASSWORD
            - name: CHE_INFRA_OPENSHIFT_PROJECT
              value: eclipse-che
            - name: CHE_INFRA_KUBERNETES_PVC_STRATEGY
              value: unique
            - name: CHE_INFRA_KUBERNETES_PVC_PRECREATE__SUBPATHS
              value: 'false'
            - name: CHE_INFRA_OPENSHIFT_TLS__ENABLED
              value: 'false'
            - name: CHE_INFRA_KUBERNETES_TRUST__CERTS
              value: 'false'
            - name: CHE_LOGS_DIR
              value: /data/logs
            - name: CHE_LOG_LEVEL
              value: INFO
            - name: CHE_KEYCLOAK_AUTH__SERVER__URL
              value: '${PROTOCOL}://keycloak-${NAMESPACE}.${ROUTING_SUFFIX}/auth'
            - name: CHE_INFRA_OPENSHIFT_OAUTH__IDENTITY__PROVIDER
              value: 'NULL'
            - name: CHE_PREDEFINED_STACKS_RELOAD__ON__START
              value: 'true'
            - name: JAVA_OPTS
              value: >-
                -XX:MaxRAMFraction=2 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10
                -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4
                -XX:AdaptiveSizePolicyWeight=90 -XX:+UnlockExperimentalVMOptions
                -XX:+UseCGroupMemoryLimitForHeap
                -Dsun.zip.disableMemoryMapping=true -Xms20m
            - name: CHE_WORKSPACE_AUTO_START
              value: 'false'
            - name: CHE_INFRA_KUBERNETES_PVC_QUANTITY
              value: 1Gi
            - name: PROTOCOL
              value: http
            - name: ROUTING_SUFFIX
              value: 172.19.20.234.nip.io
            - name: OPENSHIFT_IDENTITY_PROVIDER_CERTIFICATE
              valueFrom:
                secretKeyRef:
                  key: ca.crt
                  name: openshift-identity-provider
                  optional: true
            - name: CHE_WORKSPACE_PLUGIN__REGISTRY__URL
              value: 'NULL'
          image: 'eclipse/che-server:latest'
          imagePullPolicy: Always
          livenessProbe:
            failureThreshold: 3
            httpGet:
              path: /api/system/state
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 50
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 2
          name: che
          ports:
            - containerPort: 8080
              name: http
              protocol: TCP
          readinessProbe:
            failureThreshold: 5
            httpGet:
              path: /api/system/state
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 25
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 5
          resources:
            limits:
              memory: 1Gi
            requests:
              memory: 256Mi
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - mountPath: /data
              name: che-data-volume
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      serviceAccount: che
      serviceAccountName: che
      terminationGracePeriodSeconds: 360
      volumes:
        - name: che-data-volume
          persistentVolumeClaim:
            claimName: che-data-volume
  test: false
  triggers:
    - type: ConfigChange
status:
  availableReplicas: 1
  conditions:
    - lastTransitionTime: '2018-07-17T12:49:00Z'
      lastUpdateTime: '2018-07-17T12:49:00Z'
      message: Deployment config has minimum availability.
      status: 'True'
      type: Available
    - lastTransitionTime: '2018-07-17T12:47:37Z'
      lastUpdateTime: '2018-07-17T12:49:29Z'
      message: replication controller "che-4" successfully rolled out
      reason: NewReplicationControllerAvailable
      status: 'True'
      type: Progressing
  details:
    causes:
      - type: ConfigChange
    message: config change
  latestVersion: 4
  observedGeneration: 4
  readyReplicas: 1
  replicas: 1
  unavailableReplicas: 0
  updatedReplicas: 1

Testing process

  • Language server initialization
  1. From the project open "openshift.yml" file.
  2. Check Finished language servers initialization, file path '/nodejs-hello-world/openshift.yaml' message in the dev-machine console.
  • Autocomplete feature
  1. From the project open "openshift.yml" file.
  2. In the opened file launch autocomplete (Ctrl+Space). Make sure that kind value is present in the proposal widget, check document window with content:Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds. Enter this value.
  3. Launch autocomplete, select PersistentVolume. Make sure that there is no errors.
  4. Go to the new line type api, launch autocomplete, make sure that apiVersion: has been passed. Launch autocomplete, v1 value should be added.
  5. Go to the new line and type me. Launch autocomplete and check that metadata: should be added.
  • Code validation feature, Comment line
  1. Open "deployment.yaml" file.
  2. Add 'a' symbol to 1:1 position and check that error marker is appeared.
  3. Click on the error marker and check Unexpected property aapiVersion message.
  4. Restore content. Error marker should disappear.
  • Hover feature
  1. Open "deployment.yaml" file.
  2. Move mouse pointer on 'kind:' text in line 2, wait hover popup and check Kind is a string value representing the REST resource this object represents. message in it.
  3. Move mouse pointer on 'apiVersion:' text in line 1, wait hover popup and check APIVersion defines the versioned schema of this representation of an object. message in it.
  • Comment code feature:
  1. Select any line of code.
  2. Comment this line by Ctrl+/ buttons and check that the line is commented.
  3. Launch comment feature again and check that the line uncommented.

Go To Symbol

  1. Open "deployment.yaml" file.
  2. Start Go To Symbol feature by Ctrl+F12 buttons or from Assistant menu.
  3. Wait for Go To Symbol form is opened with next lines:
apiVersion symbols(194)
kind
metadata
annotations
openshift.io/generated-by
creationTimestamp
generation
labels
app
  1. Click on any of them and check that it correctly selected in file.