"undefined package " by Ballerina with kubernetes within Visual Code

7/14/2018

Ballerina extension was installed successfully in visual code. Also I configured ballerina.home to point to the installed package

ballerina.home = "/Library/Ballerina/ballerina-0.975.1"

Visual code is linting correctly. However, when I introduced @kubernetes:* annotations:

import ballerina/http;
import ballerina/log;

@kubernetes:Deployment {
    enableLiveness: true,
    image: "ballerina/ballerina-platform",
    name: "ballerina-abdennour-demo"
}

@kubernetes:Service {
    serviceType: "NodePort",
    name: "ballerina-abdennour-demo"

}
service<http:Service> hello bind { port: 9090 } {
    sayHello (endpoint caller, http:Request request) {
        http:Response res = new;
        res.setPayload("Hello World from Ballerina Service");
        caller ->respond(res) but { error e => log:printError("Error sending response", err = e)};

    }
}

VisualCode reports an error :

undefined package "kubernetes"
undefined annotation "Deployment"

Nevertheless, I have minikube up and running, and I don't know if I need another extension, so VisualCode can detect running clusters?

Or is it a package that is missing and should be installed inside Ballerina SDK/ Platform?

UPDATE

I am running ballerina build file.bal, and I can see this errors :

enter image description here

Any thoughts ?

-- Abdennour TOUMI
ballerina
kubernetes
minikube

2 Answers

7/14/2018

Solved! Just add the import instruction at the beginning of the file

import ballerinax/kubernetes;

Note, it is ballerinax/kubernetes and not ballerina/kubernetes (add x)

-- Abdennour TOUMI
Source: StackOverflow

7/14/2018

The fine manual very clearly shows that one must import the kubernetes package just like any other. I agree it's a bad error message on their part, so feel free to submit a bug in their repo explaining how to improve your experience

-- mdaniel
Source: StackOverflow