mirror of
https://github.com/rancher/rke.git
synced 2025-08-02 07:43:04 +00:00
Use rancher/types
This commit is contained in:
parent
e691df23b3
commit
40b13446a7
@ -3,7 +3,7 @@ package cluster
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -5,9 +5,9 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/rancher/rke/k8s"
|
||||
"github.com/rancher/rke/pki"
|
||||
"github.com/sirupsen/logrus"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/util/cert"
|
||||
)
|
||||
|
@ -4,11 +4,11 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/alena1108/cluster-controller/client/v1"
|
||||
"github.com/rancher/rke/hosts"
|
||||
"github.com/rancher/rke/pki"
|
||||
"github.com/rancher/rke/services"
|
||||
"github.com/rancher/types/io.cattle.cluster/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
)
|
||||
|
@ -3,10 +3,10 @@ package cluster
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/rancher/rke/hosts"
|
||||
"github.com/rancher/rke/pki"
|
||||
"github.com/rancher/rke/services"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func (c *Cluster) TunnelHosts() error {
|
||||
|
@ -4,11 +4,11 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/rancher/rke/docker"
|
||||
"github.com/rancher/rke/pki"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -3,7 +3,7 @@ package cluster
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -4,13 +4,13 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/rancher/rke/hosts"
|
||||
"github.com/rancher/rke/k8s"
|
||||
"github.com/rancher/rke/pki"
|
||||
"github.com/sirupsen/logrus"
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
)
|
||||
|
||||
func (c *Cluster) SaveClusterState(clusterFile string) error {
|
||||
|
@ -6,9 +6,9 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/rancher/rke/cluster"
|
||||
"github.com/rancher/rke/pki"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
"k8s.io/client-go/util/cert"
|
||||
)
|
||||
|
@ -7,10 +7,10 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func DoRunContainer(dClient *client.Client, imageCfg *container.Config, hostCfg *container.HostConfig, containerName string, hostname string, plane string) error {
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package hosts
|
||||
|
||||
import (
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/alena1108/cluster-controller/client/v1"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/rancher/rke/k8s"
|
||||
"github.com/rancher/types/io.cattle.cluster/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
)
|
||||
|
||||
|
19
k8s/k8s.go
19
k8s/k8s.go
@ -1,10 +1,10 @@
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
)
|
||||
|
||||
@ -31,11 +31,12 @@ func UpdateConfigMap(k8sClient *kubernetes.Clientset, configYaml []byte, configM
|
||||
configMapName: string(configYaml),
|
||||
},
|
||||
}
|
||||
if _, err := k8sClient.ConfigMaps(metav1.NamespaceSystem).Create(cfgMap); err != nil {
|
||||
|
||||
if _, err := k8sClient.CoreV1().ConfigMaps(metav1.NamespaceSystem).Create(cfgMap); err != nil {
|
||||
if !apierrors.IsAlreadyExists(err) {
|
||||
return err
|
||||
}
|
||||
if _, err := k8sClient.ConfigMaps(metav1.NamespaceSystem).Update(cfgMap); err != nil {
|
||||
if _, err := k8sClient.CoreV1().ConfigMaps(metav1.NamespaceSystem).Update(cfgMap); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -43,7 +44,7 @@ func UpdateConfigMap(k8sClient *kubernetes.Clientset, configYaml []byte, configM
|
||||
}
|
||||
|
||||
func GetConfigMap(k8sClient *kubernetes.Clientset, configMapName string) (*v1.ConfigMap, error) {
|
||||
return k8sClient.ConfigMaps(metav1.NamespaceSystem).Get(configMapName, metav1.GetOptions{})
|
||||
return k8sClient.CoreV1().ConfigMaps(metav1.NamespaceSystem).Get(configMapName, metav1.GetOptions{})
|
||||
}
|
||||
|
||||
func UpdateSecret(k8sClient *kubernetes.Clientset, fieldName string, secretData []byte, secretName string) error {
|
||||
@ -56,12 +57,12 @@ func UpdateSecret(k8sClient *kubernetes.Clientset, fieldName string, secretData
|
||||
fieldName: secretData,
|
||||
},
|
||||
}
|
||||
if _, err := k8sClient.Secrets(metav1.NamespaceSystem).Create(secret); err != nil {
|
||||
if _, err := k8sClient.CoreV1().Secrets(metav1.NamespaceSystem).Create(secret); err != nil {
|
||||
if !apierrors.IsAlreadyExists(err) {
|
||||
return err
|
||||
}
|
||||
// update secret if its already exist
|
||||
oldSecret, err := k8sClient.Secrets(metav1.NamespaceSystem).Get(secretName, metav1.GetOptions{})
|
||||
oldSecret, err := k8sClient.CoreV1().Secrets(metav1.NamespaceSystem).Get(secretName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -74,7 +75,7 @@ func UpdateSecret(k8sClient *kubernetes.Clientset, fieldName string, secretData
|
||||
},
|
||||
Data: newData,
|
||||
}
|
||||
if _, err := k8sClient.Secrets(metav1.NamespaceSystem).Update(secret); err != nil {
|
||||
if _, err := k8sClient.CoreV1().Secrets(metav1.NamespaceSystem).Update(secret); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -82,9 +83,9 @@ func UpdateSecret(k8sClient *kubernetes.Clientset, fieldName string, secretData
|
||||
}
|
||||
|
||||
func GetSecret(k8sClient *kubernetes.Clientset, secretName string) (*v1.Secret, error) {
|
||||
return k8sClient.Secrets(metav1.NamespaceSystem).Get(secretName, metav1.GetOptions{})
|
||||
return k8sClient.CoreV1().Secrets(metav1.NamespaceSystem).Get(secretName, metav1.GetOptions{})
|
||||
}
|
||||
|
||||
func DeleteNode(k8sClient *kubernetes.Clientset, nodeName string) error {
|
||||
return k8sClient.Nodes().Delete(nodeName, &metav1.DeleteOptions{})
|
||||
return k8sClient.CoreV1().Nodes().Delete(nodeName, &metav1.DeleteOptions{})
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ import (
|
||||
"testing"
|
||||
|
||||
check "gopkg.in/check.v1"
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
|
2
main.go
2
main.go
@ -3,8 +3,8 @@ package main
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/rancher/rke/cmd"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -6,11 +6,11 @@ import (
|
||||
"io/ioutil"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/rancher/rke/docker"
|
||||
"github.com/rancher/rke/hosts"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func DeployCertificatesOnMasters(cpHosts []hosts.Host, crtMap map[string]CertificatePKI) error {
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/rancher/rke/hosts"
|
||||
"github.com/sirupsen/logrus"
|
||||
"k8s.io/client-go/util/cert"
|
||||
)
|
||||
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
"github.com/alena1108/cluster-controller/client/v1"
|
||||
"github.com/rancher/rke/hosts"
|
||||
"github.com/rancher/types/client/cluster/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -1,9 +1,9 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/alena1108/cluster-controller/client/v1"
|
||||
"github.com/rancher/rke/hosts"
|
||||
"github.com/rancher/types/io.cattle.cluster/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func RunControlPlane(controlHosts []hosts.Host, etcdHosts []hosts.Host, controlServices v1.RKEConfigServices) error {
|
||||
|
@ -1,12 +1,12 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/alena1108/cluster-controller/client/v1"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/rancher/rke/docker"
|
||||
"github.com/rancher/rke/hosts"
|
||||
"github.com/rancher/types/io.cattle.cluster/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func RunEtcdPlane(etcdHosts []hosts.Host, etcdService v1.ETCDService) error {
|
||||
|
@ -1,12 +1,12 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"github.com/alena1108/cluster-controller/client/v1"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/rancher/rke/docker"
|
||||
"github.com/rancher/rke/hosts"
|
||||
"github.com/rancher/rke/pki"
|
||||
"github.com/rancher/types/io.cattle.cluster/v1"
|
||||
)
|
||||
|
||||
func runKubeAPI(host hosts.Host, etcdHosts []hosts.Host, kubeAPIService v1.KubeAPIService) error {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"github.com/alena1108/cluster-controller/client/v1"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/rancher/rke/docker"
|
||||
"github.com/rancher/rke/hosts"
|
||||
"github.com/rancher/rke/pki"
|
||||
"github.com/rancher/types/io.cattle.cluster/v1"
|
||||
)
|
||||
|
||||
func runKubeController(host hosts.Host, kubeControllerService v1.KubeControllerService) error {
|
||||
|
@ -1,12 +1,12 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"github.com/alena1108/cluster-controller/client/v1"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/rancher/rke/docker"
|
||||
"github.com/rancher/rke/hosts"
|
||||
"github.com/rancher/rke/pki"
|
||||
"github.com/rancher/types/io.cattle.cluster/v1"
|
||||
)
|
||||
|
||||
func runKubelet(host hosts.Host, kubeletService v1.KubeletService, isMaster bool) error {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"github.com/alena1108/cluster-controller/client/v1"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/rancher/rke/docker"
|
||||
"github.com/rancher/rke/hosts"
|
||||
"github.com/rancher/rke/pki"
|
||||
"github.com/rancher/types/io.cattle.cluster/v1"
|
||||
)
|
||||
|
||||
func runKubeproxy(host hosts.Host, kubeproxyService v1.KubeproxyService) error {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"github.com/alena1108/cluster-controller/client/v1"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/rancher/rke/docker"
|
||||
"github.com/rancher/rke/hosts"
|
||||
"github.com/rancher/rke/pki"
|
||||
"github.com/rancher/types/io.cattle.cluster/v1"
|
||||
)
|
||||
|
||||
func runScheduler(host hosts.Host, schedulerService v1.SchedulerService) error {
|
||||
|
@ -1,9 +1,9 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/alena1108/cluster-controller/client/v1"
|
||||
"github.com/rancher/rke/hosts"
|
||||
"github.com/rancher/types/io.cattle.cluster/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func RunWorkerPlane(controlHosts []hosts.Host, workerHosts []hosts.Host, workerServices v1.RKEConfigServices) error {
|
||||
|
@ -1,7 +1,7 @@
|
||||
# package
|
||||
github.com/rancher/rke
|
||||
|
||||
github.com/Sirupsen/logrus v0.10.0
|
||||
github.com/sirupsen/logrus v1.0.3
|
||||
github.com/urfave/cli v1.18.0
|
||||
golang.org/x/crypto 2509b142fb2b797aa7587dad548f113b2c0f20ce
|
||||
gopkg.in/yaml.v2 eb3733d160e74a9c7e442f435eb3bea458e1d19f
|
||||
@ -10,10 +10,13 @@ github.com/docker/distribution 3800056b8832cf6075e78b282ac010131d8687b
|
||||
github.com/docker/go-connections 3ede32e2033de7505e6500d6c868c2b9ed9f169d
|
||||
github.com/docker/go-units 0dadbb0345b35ec7ef35e228dabb8de89a65bf52
|
||||
golang.org/x/net 186fd3fc8194a5e9980a82230d69c1ff7134229f
|
||||
github.com/rancher/types 582dfda7d374d8a36dd0c7a2385d18c4c2ce5f3c
|
||||
github.com/opencontainers/go-digest 279bed98673dd5bef374d3b6e4b09e2af76183bf
|
||||
github.com/gogo/protobuf 117892bf1866fbaa2318c03e50e40564c8845457
|
||||
github.com/opencontainers/image-spec 7c889fafd04a893f5c5f50b7ab9963d5d64e5242
|
||||
github.com/pkg/errors f15c970de5b76fac0b59abb32d62c17cc7bed265
|
||||
k8s.io/client-go v4.0.0 transitive=true
|
||||
github.com/rancher/norman 068b9eb94326e2c566c5eed7636163b1b407c4c0
|
||||
gopkg.in/check.v1 11d3bc7aa68e238947792f30573146a3231fc0f1
|
||||
github.com/alena1108/cluster-controller 85168a7fe249bf97f703afe53f03d3654cc70350
|
||||
k8s.io/api/core/v1 4df58c811fe2e65feb879227b2b245e4dc26e7ad
|
||||
k8s.io/client-go v5.0.0 transitive=true
|
||||
github.com/gorilla/websocket v1.2.0
|
||||
|
Loading…
Reference in New Issue
Block a user