http

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2017 License: Apache-2.0 Imports: 14 Imported by: 7

README

k8s-client HTTP providerGoDoc

This provides a concrete, HTTP client for k8s-client.

Use this client when you actually want to contact a Kubernetes Server

License

Apache 2 License

Usage

See GoDoc for documentation.

Documentation

Overview

Package http provides an HTTP client for kubernetes

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetCA

func SetCA(cert []byte) func(*Client) error

SetCA sets a CA to verify the servers certificate

func SetCAFromFile

func SetCAFromFile(path string) func(*Client) error

SetCA sets a CA to verify the servers certificate from a file

func SetClient

func SetClient(client *http.Client) func(*Client) error

SetClient allows the caller to specify a custom http.Client to use

func SetClientCert

func SetClientCert(cert []byte) func(*Client) error

SetClientCert sets the certificate to be used for authentication.

func SetClientCertFromFile

func SetClientCertFromFile(path string) func(*Client) error

SetClientCertFromFile sets the certificate to be used for authentication from a file.

func SetClientKey

func SetClientKey(key []byte) func(*Client) error

SetClientKey sets the key to be used for authentication.

func SetClientKeyFromFile

func SetClientKeyFromFile(path string) func(*Client) error

SetClientKeyFromFile sets the key to be used for authentication from a file.

func SetInsecureSkipVerify

func SetInsecureSkipVerify(skip bool) func(*Client) error

SetInsecureSkipVerify allows the caller to skip verification of the servers cert

func SetPassword

func SetPassword(password string) func(*Client) error

SetPassword sets the password to be used for authentication.

func SetServer

func SetServer(server string) func(*Client) error

SetServer sets the target API server

func SetToken

func SetToken(token string) func(*Client) error

SetToken sets the token to be used for authentication. If this is set, it takes precedence.

func SetUsername

func SetUsername(username string) func(*Client) error

SetUsername sets the username to be used for authentication.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an http client for kubernetes

func New

func New(options ...OptionsFunc) (*Client, error)

New creates a new client.

Example
package main

import (
	"fmt"
	"os"

	"github.com/bakins/k8s-client/http"
)

func main() {

	// get server from environment
	server := os.Getenv("K8S_SERVER")
	if server == "" {
		server = "http://127.0.0.1:8001"
	}

	opts := []http.OptionsFunc{
		http.SetServer(server),
	}

	if caFile := os.Getenv("K8S_CAFILE"); caFile != "" {
		opts = append(opts, http.SetCAFromFile(caFile))
	}

	if token := os.Getenv("K8S_TOKEN"); token != "" {
		opts = append(opts, http.SetToken(token))
	}

	// create a new client using the options
	c, err := http.New(opts...)

	if err != nil {
		// handle the error
	}

	// get a list of all the name spaces
	list, err := c.ListNamespaces(nil)
	if err != nil {
		// handle the error
	}

	for _, v := range list.Items {
		fmt.Println(v.Name)
	}
}
Output:

func NewInCluster

func NewInCluster() (*Client, error)

NewInCluster creates a cluster suitable for use within the kubernetes cluster.

Example
package main

import (
	"fmt"

	"github.com/bakins/k8s-client/http"
)

func main() {
	// NewInCluster will use the environment and the service account files to create a new client
	c, err := http.NewInCluster()

	// get a list of all the name spaces
	list, err := c.ListNamespaces(nil)
	if err != nil {
		// handle the error
	}

	for _, v := range list.Items {
		fmt.Println(v.Name)
	}
}
Output:

func (*Client) CreateConfigMap

func (c *Client) CreateConfigMap(namespace string, item *k8s.ConfigMap) (*k8s.ConfigMap, error)

CreateConfigMap creates a new ConfigMap. This will fail if it already exists.

func (*Client) CreateDaemonSet

func (c *Client) CreateDaemonSet(namespace string, item *k8s.DaemonSet) (*k8s.DaemonSet, error)

CreateDaemonSet creates a new DaemonSet. This will fail if it already exists.

func (*Client) CreateDeployment

func (c *Client) CreateDeployment(namespace string, item *k8s.Deployment) (*k8s.Deployment, error)

CreateDeployment creates a new Deployment. This will fail if it already exists.

func (*Client) CreateEndpoints

func (c *Client) CreateEndpoints(namespace string, item *k8s.Endpoints) (*k8s.Endpoints, error)

CreateEndpoints creates a new Endpoints. This will fail if it already exists.

func (*Client) CreateHorizontalPodAutoscaler

func (c *Client) CreateHorizontalPodAutoscaler(namespace string, item *k8s.HorizontalPodAutoscaler) (*k8s.HorizontalPodAutoscaler, error)

CreateHorizontalPodAutoscaler creates a new HorizontalPodAutoscaler. This will fail if it already exists.

func (*Client) CreateIngress

func (c *Client) CreateIngress(namespace string, item *k8s.Ingress) (*k8s.Ingress, error)

CreateIngress creates a new Ingress. This will fail if it already exists.

func (*Client) CreateJob

func (c *Client) CreateJob(namespace string, item *k8s.Job) (*k8s.Job, error)

CreateJob creates a new Job. This will fail if it already exists.

func (*Client) CreateNamespace

func (c *Client) CreateNamespace(item *k8s.Namespace) (*k8s.Namespace, error)

CreateNamespace creates a new namespace. It will fail if the namespace already exists.

func (*Client) CreateNode

func (c *Client) CreateNode(item *k8s.Node) (*k8s.Node, error)

CreateNode creates a single node. It will fail if it already exists.

func (*Client) CreatePod

func (c *Client) CreatePod(namespace string, item *k8s.Pod) (*k8s.Pod, error)

CreatePod creates a new Pod. This will fail if it already exists.

func (*Client) CreateReplicaSet

func (c *Client) CreateReplicaSet(namespace string, item *k8s.ReplicaSet) (*k8s.ReplicaSet, error)

CreateReplicaSet creates a new ReplicaSet. This will fail if it already exists.

func (*Client) CreateSecret

func (c *Client) CreateSecret(namespace string, item *k8s.Secret) (*k8s.Secret, error)

CreateSecret creates a new Secret. This will fail if it already exists.

func (*Client) CreateService

func (c *Client) CreateService(namespace string, item *k8s.Service) (*k8s.Service, error)

CreateService creates a new Service. This will fail if it already exists.

func (*Client) CreateServiceAccount

func (c *Client) CreateServiceAccount(namespace string, item *k8s.ServiceAccount) (*k8s.ServiceAccount, error)

CreateServiceAccount creates a new ServiceAccount. This will fail if it already exists.

func (*Client) DeleteConfigMap

func (c *Client) DeleteConfigMap(namespace, name string) error

DeleteConfigMap deletes a single ConfigMap. It will error if the ConfigMap does not exist.

func (*Client) DeleteDaemonSet

func (c *Client) DeleteDaemonSet(namespace, name string) error

DeleteDaemonSet deletes a single DaemonSet. It will error if the DaemonSet does not exist.

func (*Client) DeleteDeployment

func (c *Client) DeleteDeployment(namespace, name string) error

DeleteDeployment deletes a single Deployment. It will error if the Deployment does not exist.

func (*Client) DeleteEndpoints

func (c *Client) DeleteEndpoints(namespace, name string) error

DeleteEndpoints deletes a single Endpoints. It will error if the Endpoints does not exist.

func (*Client) DeleteHorizontalPodAutoscaler

func (c *Client) DeleteHorizontalPodAutoscaler(namespace, name string) error

DeleteHorizontalPodAutoscaler deletes a single HorizontalPodAutoscaler. It will error if the HorizontalPodAutoscaler does not exist.

func (*Client) DeleteIngress

func (c *Client) DeleteIngress(namespace, name string) error

DeleteIngress deletes a single Ingress. It will error if the Ingress does not exist.

func (*Client) DeleteJob

func (c *Client) DeleteJob(namespace, name string) error

DeleteJob deletes a single Job. It will error if the Job does not exist.

func (*Client) DeleteNamespace

func (c *Client) DeleteNamespace(name string) error

DeleteNamespace deletes a single namespace. It will error it it does not exist.

func (*Client) DeleteNode

func (c *Client) DeleteNode(name string) error

DeleteNode removes a single node.

func (*Client) DeletePod

func (c *Client) DeletePod(namespace, name string) error

DeletePod deletes a single Pod. It will error if the Pod does not exist.

func (*Client) DeleteReplicaSet

func (c *Client) DeleteReplicaSet(namespace, name string) error

DeleteReplicaSet deletes a single ReplicaSet. It will error if the ReplicaSet does not exist.

func (*Client) DeleteSecret

func (c *Client) DeleteSecret(namespace, name string) error

DeleteSecret deletes a single Secret. It will error if the Secret does not exist.

func (*Client) DeleteService

func (c *Client) DeleteService(namespace, name string) error

DeleteService deletes a single Service. It will error if the Service does not exist.

func (*Client) DeleteServiceAccount

func (c *Client) DeleteServiceAccount(namespace, name string) error

DeleteServiceAccount deletes a single ServiceAccount. It will error if the ServiceAccount does not exist.

func (*Client) GetConfigMap

func (c *Client) GetConfigMap(namespace, name string) (*k8s.ConfigMap, error)

GetConfigMap fetches a single ConfigMap

func (*Client) GetDaemonSet

func (c *Client) GetDaemonSet(namespace, name string) (*k8s.DaemonSet, error)

GetDaemonSet fetches a single DaemonSet

func (*Client) GetDeployment

func (c *Client) GetDeployment(namespace, name string) (*k8s.Deployment, error)

GetDeployment fetches a single Deployment

func (*Client) GetEndpoints

func (c *Client) GetEndpoints(namespace, name string) (*k8s.Endpoints, error)

GetEndpoints fetches a single Endpoints

func (*Client) GetHorizontalPodAutoscaler

func (c *Client) GetHorizontalPodAutoscaler(namespace, name string) (*k8s.HorizontalPodAutoscaler, error)

GetHorizontalPodAutoscaler fetches a single HorizontalPodAutoscaler

func (*Client) GetIngress

func (c *Client) GetIngress(namespace, name string) (*k8s.Ingress, error)

GetIngress fetches a single Ingress

func (*Client) GetJob

func (c *Client) GetJob(namespace, name string) (*k8s.Job, error)

GetJob fetches a single Job

func (*Client) GetNamespace

func (c *Client) GetNamespace(name string) (*k8s.Namespace, error)

GetNamespace gets a namespace

func (*Client) GetNode

func (c *Client) GetNode(name string) (*k8s.Node, error)

GetNode gets a single node.

func (*Client) GetPod

func (c *Client) GetPod(namespace, name string) (*k8s.Pod, error)

GetPod fetches a single Pod

func (*Client) GetReplicaSet

func (c *Client) GetReplicaSet(namespace, name string) (*k8s.ReplicaSet, error)

GetReplicaSet fetches a single ReplicaSet

func (*Client) GetSecret

func (c *Client) GetSecret(namespace, name string) (*k8s.Secret, error)

GetSecret fetches a single Secret

func (*Client) GetService

func (c *Client) GetService(namespace, name string) (*k8s.Service, error)

GetService fetches a single Service

func (*Client) GetServiceAccount

func (c *Client) GetServiceAccount(namespace, name string) (*k8s.ServiceAccount, error)

GetServiceAccount fetches a single ServiceAccount

func (*Client) ListConfigMaps

func (c *Client) ListConfigMaps(namespace string, opts *k8s.ListOptions) (*k8s.ConfigMapList, error)

ListConfigMaps lists all ConfigMaps in a namespace

func (*Client) ListDaemonSets

func (c *Client) ListDaemonSets(namespace string, opts *k8s.ListOptions) (*k8s.DaemonSetList, error)

ListDaemonSets lists all DaemonSets in a namespace

func (*Client) ListDeployments

func (c *Client) ListDeployments(namespace string, opts *k8s.ListOptions) (*k8s.DeploymentList, error)

ListDeployments lists all Deployments in a namespace

func (*Client) ListEndpoints

func (c *Client) ListEndpoints(namespace string, opts *k8s.ListOptions) (*k8s.EndpointsList, error)

ListEndpoints lists all Endpointss in a namespace

func (*Client) ListHorizontalPodAutoscalers

func (c *Client) ListHorizontalPodAutoscalers(namespace string, opts *k8s.ListOptions) (*k8s.HorizontalPodAutoscalerList, error)

ListHorizontalPodAutoscalers lists all HorizontalPodAutoscalers in a namespace

func (*Client) ListIngresses

func (c *Client) ListIngresses(namespace string, opts *k8s.ListOptions) (*k8s.IngressList, error)

ListIngresses lists all Ingresss in a namespace

func (*Client) ListJobs

func (c *Client) ListJobs(namespace string, opts *k8s.ListOptions) (*k8s.JobList, error)

ListJobs lists all Jobs in a namespace

func (*Client) ListNamespaces

func (c *Client) ListNamespaces(opts *k8s.ListOptions) (*k8s.NamespaceList, error)

ListNamespaces list all namespaces, optionally filtering.

func (*Client) ListNodes

func (c *Client) ListNodes(opts *k8s.ListOptions) (*k8s.NodeList, error)

ListNodes list all nodes, optionally filtering.

func (*Client) ListPods

func (c *Client) ListPods(namespace string, opts *k8s.ListOptions) (*k8s.PodList, error)

ListPods lists all Pods in a namespace

func (*Client) ListReplicaSets

func (c *Client) ListReplicaSets(namespace string, opts *k8s.ListOptions) (*k8s.ReplicaSetList, error)

ListReplicaSets lists all ReplicaSets in a namespace

func (*Client) ListSecrets

func (c *Client) ListSecrets(namespace string, opts *k8s.ListOptions) (*k8s.SecretList, error)

ListSecrets lists all Secrets in a namespace

func (*Client) ListServiceAccounts

func (c *Client) ListServiceAccounts(namespace string, opts *k8s.ListOptions) (*k8s.ServiceAccountList, error)

ListServiceAccounts lists all ServiceAccounts in a namespace

func (*Client) ListServices

func (c *Client) ListServices(namespace string, opts *k8s.ListOptions) (*k8s.ServiceList, error)

ListServices lists all Services in a namespace

func (*Client) UpdateConfigMap

func (c *Client) UpdateConfigMap(namespace string, item *k8s.ConfigMap) (*k8s.ConfigMap, error)

UpdateConfigMap will update in place a single ConfigMap. Generally, you should call Get and then use that object for updates to ensure resource versions avoid update conflicts

func (*Client) UpdateDaemonSet

func (c *Client) UpdateDaemonSet(namespace string, item *k8s.DaemonSet) (*k8s.DaemonSet, error)

UpdateDaemonSet will update in place a single DaemonSet. Generally, you should call Get and then use that object for updates to ensure resource versions avoid update conflicts

func (*Client) UpdateDeployment

func (c *Client) UpdateDeployment(namespace string, item *k8s.Deployment) (*k8s.Deployment, error)

UpdateDeployment will update in place a single Deployment. Generally, you should call Get and then use that object for updates to ensure resource versions avoid update conflicts

func (*Client) UpdateEndpoints

func (c *Client) UpdateEndpoints(namespace string, item *k8s.Endpoints) (*k8s.Endpoints, error)

UpdateEndpoints will update in place a single Endpoints. Generally, you should call Get and then use that object for updates to ensure resource versions avoid update conflicts

func (*Client) UpdateHorizontalPodAutoscaler

func (c *Client) UpdateHorizontalPodAutoscaler(namespace string, item *k8s.HorizontalPodAutoscaler) (*k8s.HorizontalPodAutoscaler, error)

UpdateHorizontalPodAutoscaler will update in place a single HorizontalPodAutoscaler. Generally, you should call Get and then use that object for updates to ensure resource versions avoid update conflicts

func (*Client) UpdateIngress

func (c *Client) UpdateIngress(namespace string, item *k8s.Ingress) (*k8s.Ingress, error)

UpdateIngress will update in place a single Ingress. Generally, you should call Get and then use that object for updates to ensure resource versions avoid update conflicts

func (*Client) UpdateJob

func (c *Client) UpdateJob(namespace string, item *k8s.Job) (*k8s.Job, error)

UpdateJob will update in place a single Job. Generally, you should call Get and then use that object for updates to ensure resource versions avoid update conflicts

func (*Client) UpdateNamespace

func (c *Client) UpdateNamespace(item *k8s.Namespace) (*k8s.Namespace, error)

UpdateNamespace updates a namespace.

func (*Client) UpdateNode

func (c *Client) UpdateNode(item *k8s.Node) (*k8s.Node, error)

UpdateNode updates s sinle node.

func (*Client) UpdatePod

func (c *Client) UpdatePod(namespace string, item *k8s.Pod) (*k8s.Pod, error)

UpdatePod will update in place a single Pod. Generally, you should call Get and then use that object for updates to ensure resource versions avoid update conflicts

func (*Client) UpdateReplicaSet

func (c *Client) UpdateReplicaSet(namespace string, item *k8s.ReplicaSet) (*k8s.ReplicaSet, error)

UpdateReplicaSet will update in place a single ReplicaSet. Generally, you should call Get and then use that object for updates to ensure resource versions avoid update conflicts

func (*Client) UpdateSecret

func (c *Client) UpdateSecret(namespace string, item *k8s.Secret) (*k8s.Secret, error)

UpdateSecret will update in place a single Secret. Generally, you should call Get and then use that object for updates to ensure resource versions avoid update conflicts

func (*Client) UpdateService

func (c *Client) UpdateService(namespace string, item *k8s.Service) (*k8s.Service, error)

UpdateService will update in place a single Service. Generally, you should call Get and then use that object for updates to ensure resource versions avoid update conflicts

func (*Client) UpdateServiceAccount

func (c *Client) UpdateServiceAccount(namespace string, item *k8s.ServiceAccount) (*k8s.ServiceAccount, error)

UpdateServiceAccount will update in place a single ServiceAccount. Generally, you should call Get and then use that object for updates to ensure resource versions avoid update conflicts

func (*Client) WatchConfigMaps

func (c *Client) WatchConfigMaps(namespace string, opts *k8s.WatchOptions, events chan k8s.ConfigMapWatchEvent) error

WatchConfigMaps watches all ConfigMap changes in a namespace

func (*Client) WatchDaemonSets

func (c *Client) WatchDaemonSets(namespace string, opts *k8s.WatchOptions, events chan k8s.DaemonSetWatchEvent) error

WatchDaemonSets watches all DaemonSet changes in a namespace

func (*Client) WatchDeployments

func (c *Client) WatchDeployments(namespace string, opts *k8s.WatchOptions, events chan k8s.DeploymentWatchEvent) error

WatchDeployments watches all Deployment changes in a namespace

func (*Client) WatchEndpoints

func (c *Client) WatchEndpoints(namespace string, opts *k8s.WatchOptions, events chan k8s.EndpointsWatchEvent) error

WatchEndpoints watches all Endpoints changes in a namespace

func (*Client) WatchHorizontalPodAutoscalers

func (c *Client) WatchHorizontalPodAutoscalers(namespace string, opts *k8s.WatchOptions, events chan k8s.HorizontalPodAutoscalerWatchEvent) error

WatchHorizontalPodAutoscalers watches all HorizontalPodAutoscaler changes in a namespace

func (*Client) WatchIngresses

func (c *Client) WatchIngresses(namespace string, opts *k8s.WatchOptions, events chan k8s.IngressWatchEvent) error

WatchIngresses watches all Ingress changes in a namespace

func (*Client) WatchJobs

func (c *Client) WatchJobs(namespace string, opts *k8s.WatchOptions, events chan k8s.JobWatchEvent) error

WatchJobs watches all Job changes in a namespace

func (*Client) WatchNamespaces

func (c *Client) WatchNamespaces(opts *k8s.WatchOptions, events chan k8s.NamespaceWatchEvent) error

WatchNamespaces watches all Namespaces changes

func (*Client) WatchNodes

func (c *Client) WatchNodes(opts *k8s.WatchOptions, events chan k8s.NodeWatchEvent) error

WatchNodes watches all Nodes changes

func (*Client) WatchPods

func (c *Client) WatchPods(namespace string, opts *k8s.WatchOptions, events chan k8s.PodWatchEvent) error

WatchPods watches all Pod changes in a namespace

func (*Client) WatchReplicaSets

func (c *Client) WatchReplicaSets(namespace string, opts *k8s.WatchOptions, events chan k8s.ReplicaSetWatchEvent) error

WatchReplicaSets watches all ReplicaSet changes in a namespace

func (*Client) WatchSecrets

func (c *Client) WatchSecrets(namespace string, opts *k8s.WatchOptions, events chan k8s.SecretWatchEvent) error

WatchSecrets watches all Secret changes in a namespace

func (*Client) WatchServiceAccounts

func (c *Client) WatchServiceAccounts(namespace string, opts *k8s.WatchOptions, events chan k8s.ServiceAccountWatchEvent) error

WatchServiceAccounts watches all ServiceAccount changes in a namespace

func (*Client) WatchServices

func (c *Client) WatchServices(namespace string, opts *k8s.WatchOptions, events chan k8s.ServiceWatchEvent) error

WatchServices watches all Service changes in a namespace

type OptionsFunc

type OptionsFunc func(*Client) error

OptionsFunc is a function passed to new for setting options on a new client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL