Access Clusters Using the Kubernetes API

Create a cluster configuration programmatically

const k8s = require('@kubernetes/client-node');

const cluster = {
    name: 'my-server',
    server: 'http://server.com',
};

const user = {
    name: 'my-user',
    password: 'some-password',
};

const context = {
    name: 'my-context',
    user: user.name,
    cluster: cluster.name,
};

const kc = new k8s.KubeConfig();
kc.loadFromOptions({
    clusters: [cluster],
    users: [user],
    contexts: [context],
    currentContext: context.name,
});
const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
...
https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/ https://github.com/kubernetes-client https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/
Java: https://github.com/kubernetes-client/java
JavaScript : https://github.com/kubernetes-client/javascript

Leave a Reply

Your email address will not be published.

ANOTE.DEV