Skip to content

Commit

Permalink
Merge pull request #14239 from marun/enable-federation
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot authored May 26, 2017
2 parents 1d30fc4 + cac7f93 commit 827f454
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 28 deletions.
21 changes: 21 additions & 0 deletions cmd/kubefed/kubefed.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package main

import (
"os"

_ "k8s.io/kubernetes/pkg/client/metrics/prometheus" // for client metric registration
"k8s.io/kubernetes/pkg/util/logs"
_ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration

"github.com/openshift/origin/pkg/federation/kubefed"
)

func main() {
logs.InitLogs()
defer logs.FlushLogs()

cmd := kubefed.NewKubeFedCommand(os.Stdin, os.Stdout, os.Stderr)
if err := cmd.Execute(); err != nil {
os.Exit(1)
}
}
1 change: 1 addition & 0 deletions hack/build-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ image "${tag_prefix}-haproxy-router" images/router/haproxy
image "${tag_prefix}-keepalived-ipfailover" images/ipfailover/keepalived
image "${tag_prefix}-docker-registry" images/dockerregistry
image "${tag_prefix}-egress-router" images/egress/router
image "${tag_prefix}-federation" images/federation
# images that depend on "${tag_prefix}
image "${tag_prefix}-gitserver" examples/gitserver
image "${tag_prefix}-deployer" images/deployer
Expand Down
4 changes: 4 additions & 0 deletions hack/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,8 @@ readonly -f os::build::save_version_vars
function os::build::get_product_vars() {
export OS_BUILD_LDFLAGS_IMAGE_PREFIX="${OS_IMAGE_PREFIX:-"openshift/origin"}"
export OS_BUILD_LDFLAGS_DEFAULT_IMAGE_STREAMS="${OS_BUILD_LDFLAGS_DEFAULT_IMAGE_STREAMS:-"centos7"}"
export OS_BUILD_LDFLAGS_FEDERATION_SERVER_IMAGE_NAME="${OS_BUILD_LDFLAGS_FEDERATION_SERVER_IMAGE_NAME:-"${OS_BUILD_LDFLAGS_IMAGE_PREFIX}-federation"}"
export OS_BUILD_LDFLAGS_FEDERATION_ETCD_IMAGE="${OS_BUILD_LDFLAGS_FEDERATION_ETCD_IMAGE:-"quay.io/coreos/etcd:v3.1.7"}"
}

# golang 1.5 wants `-X key=val`, but golang 1.4- REQUIRES `-X key val`
Expand Down Expand Up @@ -716,6 +718,8 @@ function os::build::ldflags() {
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/client-go/pkg/version.gitVersion" "${KUBE_GIT_VERSION}"))
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/client-go/pkg/version.buildDate" "${buildDate}"))
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/client-go/pkg/version.gitTreeState" "clean"))
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/pkg/federation/kubefed.serverImageName" "${OS_BUILD_LDFLAGS_FEDERATION_SERVER_IMAGE_NAME}"))
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/pkg/federation/kubefed.defaultEtcdImage" "${OS_BUILD_LDFLAGS_FEDERATION_ETCD_IMAGE}"))

# The -ldflags parameter takes a single string, so join the output.
echo "${ldflags[*]-}"
Expand Down
4 changes: 3 additions & 1 deletion hack/lib/build/constants.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ readonly OS_IMAGE_COMPILE_TARGETS_LINUX=(
images/pod
cmd/dockerregistry
cmd/gitserver
vendor/k8s.io/kubernetes/cmd/hyperkube
"${OS_SDN_COMPILE_TARGETS_LINUX[@]}"
)
readonly OS_SCRATCH_IMAGE_COMPILE_TARGETS_LINUX=(
Expand All @@ -33,6 +34,7 @@ readonly OS_IMAGE_COMPILE_BINARIES=("${OS_SCRATCH_IMAGE_COMPILE_TARGETS_LINUX[@]
readonly OS_CROSS_COMPILE_TARGETS=(
cmd/openshift
cmd/oc
cmd/kubefed
)
readonly OS_CROSS_COMPILE_BINARIES=("${OS_CROSS_COMPILE_TARGETS[@]##*/}")

Expand Down Expand Up @@ -91,4 +93,4 @@ readonly OS_BINARY_RELEASE_SERVER_LINUX=(
readonly OS_BINARY_RELEASE_CLIENT_EXTRA=(
${OS_ROOT}/README.md
${OS_ROOT}/LICENSE
)
)
16 changes: 16 additions & 0 deletions images/federation/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# This is the OpenShift Origin Federation image, used for running the
# federation apiserver and controller manager components.
#
# The standard name for this image is openshift/origin-federation
#
FROM openshift/origin-base

RUN INSTALL_PKGS="origin-federation-services" && \
yum install -y ${INSTALL_PKGS} && \
rpm -V ${INSTALL_PKGS} && \
yum clean all && \
ln -s /usr/bin/hyperkube /hyperkube

LABEL io.k8s.display-name="OpenShift Origin Federation" \
io.k8s.description="This is a component of OpenShift Origin and contains the software for running federation servers."
16 changes: 15 additions & 1 deletion origin.spec
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ Obsoletes: openshift-sdn-ovs < %{package_refector_version}
%description sdn-ovs
%{summary}

%package federation-services
Summary: %{produce_name} Federation Services
Requires: %{name} = %{version}-%{release}

%description federation-services
%{summary}

%package excluder
Summary: Exclude openshift packages from updates
BuildArch: noarch
Expand Down Expand Up @@ -240,7 +247,7 @@ PLATFORM="$(go env GOHOSTOS)/$(go env GOHOSTARCH)"
install -d %{buildroot}%{_bindir}

# Install linux components
for bin in oc openshift dockerregistry
for bin in oc openshift dockerregistry kubefed
do
echo "+++ INSTALLING ${bin}"
install -p -m 755 _output/local/bin/${PLATFORM}/${bin} %{buildroot}%{_bindir}/${bin}
Expand All @@ -256,6 +263,9 @@ install -p -m 755 _output/local/bin/darwin/amd64/oc %{buildroot}/%{_datadir}/%{n
install -p -m 755 _output/local/bin/windows/amd64/oc.exe %{buildroot}/%{_datadir}/%{name}/windows/oc.exe
%endif

# Install federation services
install -p -m 755 _output/local/bin/${PLATFORM}/hyperkube %{buildroot}%{_bindir}/

# Install pod
install -p -m 755 _output/local/bin/${PLATFORM}/pod %{buildroot}%{_bindir}/

Expand Down Expand Up @@ -541,6 +551,7 @@ fi
%license LICENSE
%{_bindir}/oc
%{_bindir}/kubectl
%{_bindir}/kubefed
%{_sysconfdir}/bash_completion.d/oc
%{_mandir}/man1/oc*

Expand Down Expand Up @@ -600,6 +611,9 @@ if [ "$1" -eq 0 ] ; then
/usr/sbin/%{name}-docker-excluder unexclude
fi

%files federation-services
%{_bindir}/hyperkube

%changelog
* Fri Sep 18 2015 Scott Dodson <sdodson@redhat.com> 0.2-9
- Rename from openshift -> origin
Expand Down
87 changes: 87 additions & 0 deletions pkg/federation/kubefed/kubefed.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package kubefed

import (
"fmt"
"io"

"github.com/spf13/cobra"

"k8s.io/apiserver/pkg/util/flag"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/kubernetes/federation/pkg/kubefed"
kubefedinit "k8s.io/kubernetes/federation/pkg/kubefed/init"
"k8s.io/kubernetes/federation/pkg/kubefed/util"
kubectl "k8s.io/kubernetes/pkg/kubectl/cmd"
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"

"github.com/openshift/origin/pkg/cmd/cli/cmd"
osclientcmd "github.com/openshift/origin/pkg/cmd/util/clientcmd"
"github.com/openshift/origin/pkg/version"
)

// This file was copied from vendor/k8s.io/kubernetes/federation/pkg/kubefed and
// modified to support the openshift version command as per the inline comments.

var (
// serverImageName is the name of the default image (without version)
// used for the federation services (api and controller manager). It
// should be set during build via -ldflags.
serverImageName string

// defaultEtcImage is the default image (including version) used to run
// etcd for the federation apiserver. It should be set during build via
// -ldflags.
defaultEtcdImage string
)

// NewKubeFedCommand creates the `kubefed` command and its nested children.
func NewKubeFedCommand(in io.Reader, out, err io.Writer) *cobra.Command {
defaultServerImage := fmt.Sprintf("%s:%s", serverImageName, version.Get())

// Parent command to which all subcommands are added.
cmds := &cobra.Command{
Use: "kubefed",
Short: "kubefed controls an OpenShift Cluster Federation",
Long: templates.LongDesc(`
kubefed controls an OpenShift Cluster Federation.
Find more information at https://github.com/openshift/origin.`),
Run: runHelp,
}

// Use an openshift command factory to ensure CmdNewVersion will work.
// It is interface compatible with the kube equivalent, so any calls to
// kube code will continue to work.
f := osclientcmd.New(cmds.PersistentFlags())

// From this point and forward we get warnings on flags that contain "_" separators
cmds.SetGlobalNormalizationFunc(flag.WarnWordSepNormalizeFunc)

groups := templates.CommandGroups{
{
Message: "Basic Commands:",
Commands: []*cobra.Command{
kubefedinit.NewCmdInit(out, util.NewAdminConfig(clientcmd.NewDefaultPathOptions()), defaultServerImage, defaultEtcdImage),
kubefed.NewCmdJoin(f, out, util.NewAdminConfig(clientcmd.NewDefaultPathOptions())),
kubefed.NewCmdUnjoin(f, out, err, util.NewAdminConfig(clientcmd.NewDefaultPathOptions())),
},
},
}
groups.Add(cmds)

filters := []string{
"options",
}
templates.ActsAsRootCommand(cmds, filters, groups...)

// Use the openshift-specific version command
cmds.AddCommand(cmd.NewCmdVersion("kubefed", f, out, cmd.VersionOptions{PrintClientFeatures: true}))

cmds.AddCommand(kubectl.NewCmdOptions(out))

return cmds
}

func runHelp(cmd *cobra.Command, args []string) {
cmd.Help()
}
10 changes: 9 additions & 1 deletion vendor/k8s.io/kubernetes/federation/cmd/kubefed/app/kubefed.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 827f454

Please sign in to comment.