Skip to content

Commit

Permalink
Merge pull request #39646 from shashidharatd/federation-misc
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue (batch tested with PRs 39714, 39646)

use etcd2 as storage-backend for federation until federation features are completely tested with etcd3

**What this PR does / why we need it**: move federation etcd to etcd3

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #39594

**Special notes for your reviewer**: here is the [link](kubernetes/enhancements#44 (comment)) to announcement making etcd3 as default

**Release note**:

```release-note
```
  • Loading branch information
Kubernetes Submit Queue authored Jan 11, 2017
2 parents cd55e1b + 9423e78 commit 3888aca
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
5 changes: 3 additions & 2 deletions federation/manifests/federation-apiserver-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ spec:
- --admission-control={{.FEDERATION_ADMISSION_CONTROL}}
- --token-auth-file=/srv/kubernetes/known-tokens.csv
- --anonymous-auth=false
- --storage-backend=etcd2
ports:
- containerPort: 443
name: https
Expand All @@ -42,9 +43,9 @@ spec:
mountPath: /srv/kubernetes/
readOnly: true
- name: etcd
image: quay.io/coreos/etcd:v2.3.3
image: gcr.io/google_containers/etcd:3.0.14-alpha.1
command:
- /etcd
- /usr/local/bin/etcd
- --data-dir
- /var/etcd/data
volumeMounts:
Expand Down
11 changes: 7 additions & 4 deletions federation/pkg/kubefed/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func NewCmdInit(cmdOut io.Writer, config util.AdminConfig) *cobra.Command {
cmd.Flags().String("dns-provider", "google-clouddns", "Dns provider to be used for this deployment.")
cmd.Flags().String("etcd-pv-capacity", "10Gi", "Size of persistent volume claim to be used for etcd.")
cmd.Flags().Bool("dry-run", false, "dry run without sending commands to server.")
cmd.Flags().String("storage-backend", "etcd2", "The storage backend for persistence. Options: 'etcd2' (default), 'etcd3'.")
return cmd
}

Expand All @@ -146,6 +147,7 @@ func initFederation(cmdOut io.Writer, config util.AdminConfig, cmd *cobra.Comman
dnsProvider := cmdutil.GetFlagString(cmd, "dns-provider")
etcdPVCapacity := cmdutil.GetFlagString(cmd, "etcd-pv-capacity")
dryRun := cmdutil.GetDryRunFlag(cmd)
storageBackend := cmdutil.GetFlagString(cmd, "storage-backend")

hostFactory := config.HostFactory(initFlags.Host, initFlags.Kubeconfig)
hostClientset, err := hostFactory.ClientSet()
Expand Down Expand Up @@ -212,7 +214,7 @@ func initFederation(cmdOut io.Writer, config util.AdminConfig, cmd *cobra.Comman
}

// 6. Create federation API server
_, err = createAPIServer(hostClientset, initFlags.FederationSystemNamespace, serverName, image, serverCredName, pvc.Name, advertiseAddress, dryRun)
_, err = createAPIServer(hostClientset, initFlags.FederationSystemNamespace, serverName, image, serverCredName, pvc.Name, advertiseAddress, storageBackend, dryRun)
if err != nil {
return err
}
Expand Down Expand Up @@ -416,7 +418,7 @@ func createPVC(clientset *client.Clientset, namespace, svcName, etcdPVCapacity s
return clientset.Core().PersistentVolumeClaims(namespace).Create(pvc)
}

func createAPIServer(clientset *client.Clientset, namespace, name, image, credentialsName, pvcName, advertiseAddress string, dryRun bool) (*extensions.Deployment, error) {
func createAPIServer(clientset *client.Clientset, namespace, name, image, credentialsName, pvcName, advertiseAddress, storageBackend string, dryRun bool) (*extensions.Deployment, error) {
command := []string{
"/hyperkube",
"federation-apiserver",
Expand All @@ -426,6 +428,7 @@ func createAPIServer(clientset *client.Clientset, namespace, name, image, creden
"--client-ca-file=/etc/federation/apiserver/ca.crt",
"--tls-cert-file=/etc/federation/apiserver/server.crt",
"--tls-private-key-file=/etc/federation/apiserver/server.key",
fmt.Sprintf("--storage-backend=%s", storageBackend),
}

if advertiseAddress != "" {
Expand Down Expand Up @@ -473,9 +476,9 @@ func createAPIServer(clientset *client.Clientset, namespace, name, image, creden
},
{
Name: "etcd",
Image: "quay.io/coreos/etcd:v2.3.3",
Image: "gcr.io/google_containers/etcd:3.0.14-alpha.1",
Command: []string{
"/etcd",
"/usr/local/bin/etcd",
"--data-dir",
"/var/etcd/data",
},
Expand Down
29 changes: 25 additions & 4 deletions federation/pkg/kubefed/init/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func TestInitFederation(t *testing.T) {
etcdPVCapacity string
expectedErr string
dnsProvider string
storageBackend string
dryRun string
}{
{
Expand All @@ -91,6 +92,7 @@ func TestInitFederation(t *testing.T) {
etcdPVCapacity: "5Gi",
expectedErr: "",
dnsProvider: "test-dns-provider",
storageBackend: "etcd2",
dryRun: "",
},
{
Expand All @@ -103,6 +105,7 @@ func TestInitFederation(t *testing.T) {
etcdPVCapacity: "", //test for default value of pvc-size
expectedErr: "",
dnsProvider: "", //test for default value of dns provider
storageBackend: "etcd2",
dryRun: "",
},
{
Expand All @@ -115,8 +118,22 @@ func TestInitFederation(t *testing.T) {
etcdPVCapacity: "",
expectedErr: "",
dnsProvider: "test-dns-provider",
storageBackend: "etcd2",
dryRun: "valid-run",
},
{
federation: "union",
kubeconfigGlobal: fakeKubeFiles[0],
kubeconfigExplicit: "",
dnsZoneName: "example.test.",
lbIP: "10.20.30.40",
image: "example.test/foo:bar",
etcdPVCapacity: "5Gi",
expectedErr: "",
dnsProvider: "test-dns-provider",
storageBackend: "etcd3",
dryRun: "",
},
}

//TODO: implement a negative case for dry run
Expand All @@ -131,7 +148,7 @@ func TestInitFederation(t *testing.T) {
} else {
dnsProvider = "google-clouddns" //default value of dns-provider
}
hostFactory, err := fakeInitHostFactory(tc.federation, util.DefaultFederationSystemNamespace, tc.lbIP, tc.dnsZoneName, tc.image, dnsProvider, tc.etcdPVCapacity)
hostFactory, err := fakeInitHostFactory(tc.federation, util.DefaultFederationSystemNamespace, tc.lbIP, tc.dnsZoneName, tc.image, dnsProvider, tc.etcdPVCapacity, tc.storageBackend)
if err != nil {
t.Fatalf("[%d] unexpected error: %v", i, err)
}
Expand All @@ -147,6 +164,9 @@ func TestInitFederation(t *testing.T) {
cmd.Flags().Set("host-cluster-context", "substrate")
cmd.Flags().Set("dns-zone-name", tc.dnsZoneName)
cmd.Flags().Set("image", tc.image)
if tc.storageBackend != "" {
cmd.Flags().Set("storage-backend", tc.storageBackend)
}
if tc.dnsProvider != "" {
cmd.Flags().Set("dns-provider", tc.dnsProvider)
}
Expand Down Expand Up @@ -423,7 +443,7 @@ func TestCertsHTTPS(t *testing.T) {
}
}

func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image, dnsProvider, etcdPVCapacity string) (cmdutil.Factory, error) {
func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image, dnsProvider, etcdPVCapacity, storageProvider string) (cmdutil.Factory, error) {
svcName := federationName + "-apiserver"
svcUrlPrefix := "/api/v1/namespaces/federation-system/services"
credSecretName := svcName + "-credentials"
Expand Down Expand Up @@ -566,6 +586,7 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image,
"--client-ca-file=/etc/federation/apiserver/ca.crt",
"--tls-cert-file=/etc/federation/apiserver/server.crt",
"--tls-private-key-file=/etc/federation/apiserver/server.key",
fmt.Sprintf("--storage-backend=%s", storageProvider),
"--advertise-address=" + ip,
},
Ports: []v1.ContainerPort{
Expand All @@ -588,9 +609,9 @@ func fakeInitHostFactory(federationName, namespaceName, ip, dnsZoneName, image,
},
{
Name: "etcd",
Image: "quay.io/coreos/etcd:v2.3.3",
Image: "gcr.io/google_containers/etcd:3.0.14-alpha.1",
Command: []string{
"/etcd",
"/usr/local/bin/etcd",
"--data-dir",
"/var/etcd/data",
},
Expand Down

0 comments on commit 3888aca

Please sign in to comment.