podInterface := client.CoreV1().Pods("namespace") podLogs, err := podInterface.GetLogs("pod-name", &v1.PodLogOptions{}) if err != nil { // handle error } // do something with the pod logs
deployment := &v1beta1.Deployment{ ObjectMeta: meta_v1.ObjectMeta{ Name: "deployment-name", Namespace: "namespace", }, Spec: v1beta1.DeploymentSpec{ Replicas: int32Ptr(1), Template: podTemplate, Selector: selector, RevisionHistoryLimit: int32Ptr(10), }, } deploymentClient := client.ExtensionsV1beta1().Deployments("namespace") res, err := deploymentClient.Create(deployment) if err != nil { // handle error } // do something with the created deployment
watcher, err := client.CoreV1().Namespaces().Watch(meta_v1.ListOptions{}) if err != nil { // handle error } done := make(chan bool) go func() { for event := range watcher.ResultChan() { // do something with the event } done <- true }() <-done // wait for watch to be doneThis code snippet shows how to use the `Watch` method of the `corev1.NamespaceInterface` interface to watch for changes in a namespace. The `ResultChan` method of the returned `watcher` object is used to receive events. The `done` channel is used to wait for the watch to be done. In summary, the `k8s.io/kubernetes/pkg/client/unversioned` package provides extensions for the Kubernetes client API that enable developers to work more easily with Kubernetes objects and resources. The examples above demonstrate some of the functionality of this package.