Skip to content

Commit

Permalink
Merge pull request #27260 from nikhiljindal/dnsProvider
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

Updating federation up scripts to work in non e2e setup

Ref: kubernetes/website#656

Updating the federation up scripts so that they work as per steps in kubernetes/website#656.

Changes are:
* Updating the default namespace to be "federation" instead of "federation-e2e"
* Updated the kubeconfig context to be named "federation-cluster" instead of "federated-context"
* Fixing federation-up so that FEDERATION_IMAGE_TAG is set even when federation-up is run without running `e2e.go --up`. e2e-up.sh sets it here: https://github.com/kubernetes/kubernetes/blob/6a388d4a0d9e7fc2549ab89c97bf29ce53982e39/hack/e2e-internal/e2e-up.sh#L44.
* Adding a "missingkey=zero" option to template parser. Without this, the parser adds `"<no value>"` at the place of an env var that is not set. With this change, it instead replaces it with the corresponding zero value (for ex "" for strings). This is required for the FEDERATION_DNS_PROVIDER_CONFIG env var.

cc @kubernetes/sig-cluster-federation @colhom @mml
  • Loading branch information
k8s-merge-robot authored Jun 14, 2016
2 parents ff1258a + 5a20112 commit 7e2b523
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 14 deletions.
8 changes: 4 additions & 4 deletions federation/cluster/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if [[ -z "${FEDERATION_PUSH_REPO_BASE}" ]]; then
fi

FEDERATION_IMAGE_REPO_BASE=${FEDERATION_IMAGE_REPO_BASE:-'gcr.io/google_containers'}
FEDERATION_NAMESPACE=${FEDERATION_NAMESPACE:-federation-e2e}
FEDERATION_NAMESPACE=${FEDERATION_NAMESPACE:-federation}

KUBE_PLATFORM=${KUBE_PLATFORM:-linux}
KUBE_ARCH=${KUBE_ARCH:-amd64}
Expand Down Expand Up @@ -99,7 +99,7 @@ function create-federation-api-objects {

FEDERATION_KUBECONFIG_PATH="${KUBE_ROOT}/federation/cluster/kubeconfig"

federation_kubectl="${KUBE_ROOT}/cluster/kubectl.sh --context=federated-cluster --namespace=default"
federation_kubectl="${KUBE_ROOT}/cluster/kubectl.sh --context=federation-cluster --namespace=default"

manifests_root="${KUBE_ROOT}/federation/manifests/"

Expand Down Expand Up @@ -152,7 +152,7 @@ function create-federation-api-objects {
# controller manager can use to talk to the federation-apiserver.
# Note that the file name should be "kubeconfig" so that the secret key gets the same name.
KUBECONFIG_DIR=$(dirname ${KUBECONFIG:-$DEFAULT_KUBECONFIG})
CONTEXT=federated-cluster \
CONTEXT=federation-cluster \
KUBE_BEARER_TOKEN="$FEDERATION_API_TOKEN" \
KUBECONFIG="${KUBECONFIG_DIR}/federation/federation-apiserver/kubeconfig" \
create-kubeconfig
Expand All @@ -169,7 +169,7 @@ function create-federation-api-objects {
done

# Update the users kubeconfig to include federation-apiserver credentials.
CONTEXT=federated-cluster \
CONTEXT=federation-cluster \
KUBE_BEARER_TOKEN="$FEDERATION_API_TOKEN" \
SECONDARY_KUBECONFIG=true \
create-kubeconfig
Expand Down
7 changes: 7 additions & 0 deletions federation/cluster/federation-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ KUBE_ROOT=$(readlink -m $(dirname "${BASH_SOURCE}")/../../)

. ${KUBE_ROOT}/federation/cluster/common.sh

tagfile="${KUBE_ROOT}/federation/manifests/federated-image.tag"
if [[ ! -f "$tagfile" ]]; then
echo "FATAL: tagfile ${tagfile} does not exist. Make sure that you have run build/push-federation-images.sh"
exit 1
fi
export FEDERATION_IMAGE_TAG="$(cat "${KUBE_ROOT}/federation/manifests/federated-image.tag")"

create-federation-api-objects
2 changes: 1 addition & 1 deletion federation/cluster/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func main() {
}

func templateYamlFile(params map[string]string, inpath string, out io.Writer) error {
if tmpl, err := template.New(path.Base(inpath)).ParseFiles(inpath); err != nil {
if tmpl, err := template.New(path.Base(inpath)).Option("missingkey=zero").ParseFiles(inpath); err != nil {
return err
} else {
if err := tmpl.Execute(out, params); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion hack/e2e-internal/e2e-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ source "${KUBE_ROOT}/cluster/kube-util.sh"
prepare-e2e

if [[ "${FEDERATION:-}" == "true" ]];then
FEDERATION_NAMESPACE=${FEDERATION_NAMESPACE:-federation-e2e}
FEDERATION_NAMESPACE=${FEDERATION_NAMESPACE:-federation}
#TODO(colhom): the last cluster that was created in the loop above is the current context.
# Hence, it will be the cluster that hosts the federated components.
# In the future, we will want to loop through the all the federated contexts,
Expand Down
8 changes: 6 additions & 2 deletions hack/e2e-internal/e2e-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ if [[ "${FEDERATION:-}" == "true" ]];then
test-setup
)
done
if [[ -f "${KUBE_ROOT}/federation/manifests/federated-image.tag" ]];then
export FEDERATION_IMAGE_TAG="$(cat "${KUBE_ROOT}/federation/manifests/federated-image.tag")"
tagfile="${KUBE_ROOT}/federation/manifests/federated-image.tag"
if [[ ! -f "$tagfile" ]]; then
echo "FATAL: tagfile ${tagfile} does not exist. Make sure that you have run build/push-federation-images.sh"
exit 1
fi
export FEDERATION_IMAGE_TAG="$(cat "${KUBE_ROOT}/federation/manifests/federated-image.tag")"

"${KUBE_ROOT}/federation/cluster/federation-up.sh"
else
test-setup
Expand Down
27 changes: 24 additions & 3 deletions test/e2e/federation-apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ package e2e

import (
"fmt"
"time"

. "github.com/onsi/ginkgo"
federationapi "k8s.io/kubernetes/federation/apis/federation"
"k8s.io/kubernetes/federation/client/clientset_generated/federation_internalclientset"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/test/e2e/framework"
)

// Create/delete cluster api objects
var _ = framework.KubeDescribe("Federation apiserver [Feature:Federation]", func() {
f := framework.NewDefaultFederatedFramework("federated-cluster")
f := framework.NewDefaultFederatedFramework("federation-cluster")
It("should allow creation of cluster api objects", func() {
framework.SkipUnlessFederated(f.Client)

Expand All @@ -54,16 +57,34 @@ var _ = framework.KubeDescribe("Federation apiserver [Feature:Federation]", func
},
},
}
_, err := f.FederationClient.Clusters().Create(&cluster)
_, err := f.FederationClientset.Federation().Clusters().Create(&cluster)
framework.ExpectNoError(err, fmt.Sprintf("creating cluster: %+v", err))
}

for _, context := range contexts {
c, err := f.FederationClient.Clusters().Get(context.Name)
c, err := f.FederationClientset.Federation().Clusters().Get(context.Name)
framework.ExpectNoError(err, fmt.Sprintf("get cluster: %+v", err))
if c.ObjectMeta.Name != context.Name {
framework.Failf("cluster name does not match input context: actual=%+v, expected=%+v", c, context)
}
err = isReady(context.Name, f.FederationClientset)
framework.ExpectNoError(err, fmt.Sprintf("unexpected error in verifying if cluster %s is ready: %+v", context.Name, err))
}
})
})

// Verify that the cluster is marked ready.
func isReady(clusterName string, clientset *federation_internalclientset.Clientset) error {
return wait.PollImmediate(time.Second, wait.ForeverTestTimeout, func() (bool, error) {
c, err := clientset.Federation().Clusters().Get(clusterName)
if err != nil {
return false, err
}
for _, condition := range c.Status.Conditions {
if condition.Type == federationapi.ClusterReady && condition.Status == api.ConditionTrue {
return true, nil
}
}
return false, nil
})
}
2 changes: 1 addition & 1 deletion test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ func (f *Framework) GetUnderlyingFederatedContexts() []E2EContext {

e2eContexts := []E2EContext{}
for _, context := range kubeconfig.Contexts {
if strings.HasPrefix(context.Name, "federation-e2e") {
if strings.HasPrefix(context.Name, "federation") && context.Name != "federation-cluster" {

user := kubeconfig.findUser(context.Context.User)
if user == nil {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/framework/test_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func RegisterFlags() {
flag.StringVar(&TestContext.KubeConfig, clientcmd.RecommendedConfigPathFlag, os.Getenv(clientcmd.RecommendedConfigPathEnvVar), "Path to kubeconfig containing embedded authinfo.")
flag.StringVar(&TestContext.KubeContext, clientcmd.FlagContext, "", "kubeconfig context to use/override. If unset, will use value from 'current-context'")
flag.StringVar(&TestContext.KubeAPIContentType, "kube-api-content-type", "", "ContentType used to communicate with apiserver")
flag.StringVar(&federatedKubeContext, "federated-kube-context", "federated-cluster", "kubeconfig context for federated-cluster.")
flag.StringVar(&federatedKubeContext, "federated-kube-context", "federation-cluster", "kubeconfig context for federation-cluster.")

flag.StringVar(&TestContext.KubeVolumeDir, "volume-dir", "/var/lib/kubelet", "Path to the directory containing the kubelet volumes.")
flag.StringVar(&TestContext.CertDir, "cert-dir", "", "Path to the directory containing the certs. Default is empty, which doesn't use certs.")
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/framework/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func SkipUnlessServerVersionGTE(v semver.Version, c discovery.ServerVersionInter
func SkipUnlessFederated(c *client.Client) {
federationNS := os.Getenv("FEDERATION_NAMESPACE")
if federationNS == "" {
federationNS = "federation-e2e"
federationNS = "federation"
}

_, err := c.Namespaces().Get(federationNS)
Expand Down

0 comments on commit 7e2b523

Please sign in to comment.