Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cloud-node-manager for supporting IMDS #231

Merged
merged 5 commits into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 22 additions & 0 deletions Dockerfile.node
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2019 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.12.9-stretch AS build
WORKDIR /go/src/k8s.io/cloud-provider-azure
COPY . .
RUN make

FROM buildpack-deps:stretch-curl
COPY --from=build /go/src/k8s.io/cloud-provider-azure/bin/azure-cloud-node-manager /usr/local/bin
RUN ln -s /usr/local/bin/azure-cloud-node-manager /usr/local/bin/cloud-node-manager
23 changes: 13 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,36 @@ CCM_E2E_ARGS ?= -ginkgo.skip=\\[Serial\\]\\[Slow\\]
#The test args for Kubernetes e2e tests
TEST_E2E_ARGS ?= '--ginkgo.focus=Port\sforwarding'

IMAGE_NAME=azure-cloud-controller-manager
IMAGE_TAG ?= $(shell git rev-parse --short=7 HEAD)
# cloud controller manager image
IMAGE_NAME=azure-cloud-controller-manager
IMAGE=$(IMAGE_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)

TEST_IMAGE_NAME=azure-cloud-controller-manager-test
TEST_IMAGE=$(TEST_IMAGE_NAME):$(IMAGE_TAG)

WORKSPACE ?= $(shell pwd)
ARTIFACTS ?= $(WORKSPACE)/_artifactsx
# cloud node manager image
NODE_MANAGER_IMAGE_NAME=azure-cloud-node-manager
NODE_MANAGER_IMAGE=$(IMAGE_REGISTRY)/$(NODE_MANAGER_IMAGE_NAME):$(IMAGE_TAG)

# Bazel variables
BAZEL_VERSION := $(shell command -v bazel 2> /dev/null)
BAZEL_ARGS ?=

.PHONY: all
all: $(BIN_DIR)/azure-cloud-controller-manager
all: $(BIN_DIR)/azure-cloud-controller-manager $(BIN_DIR)/azure-cloud-node-manager

$(BIN_DIR)/azure-cloud-node-manager: $(PKG_CONFIG) $(wildcard cmd/cloud-node-manager/*) $(wildcard cmd/cloud-node-manager/**/*) $(wildcard pkg/**/*)
go build -o $@ $(PKG_CONFIG_CONTENT) ./cmd/cloud-node-manager

$(BIN_DIR)/azure-cloud-controller-manager: $(PKG_CONFIG) $(wildcard cmd/cloud-controller-manager/*) $(wildcard cmd/cloud-controller-manager/**/*) $(wildcard pkg/**/*)
go build -o $@ $(PKG_CONFIG_CONTENT) ./cmd/cloud-controller-manager

.PHONY: image
image:
docker build -t $(IMAGE) .
docker build -t $(NODE_MANAGER_IMAGE) -f Dockerfile.node .

.PHONY: push
push:
docker push $(IMAGE)
docker push $(NODE_MANAGER_IMAGE)

hyperkube:
ifneq ($(K8S_BRANCH), )
Expand Down Expand Up @@ -101,7 +104,7 @@ test-boilerplate:
hack/verify-boilerplate.sh

.PHONY: test-bazel
test-boilerplate:
test-bazel:
hack/verify-bazel.sh

.PHONY: update-prepare
Expand All @@ -114,7 +117,7 @@ update:
hack/update-dependencies.sh

.PHONY: update-bazel
update:
update-bazel:
hack/update-bazel.sh

.PHONY: test-update
Expand Down
3 changes: 1 addition & 2 deletions cmd/cloud-controller-manager/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ go_library(
visibility = ["//visibility:private"],
deps = [
"//cmd/cloud-controller-manager/app:go_default_library",
"//pkg/version/prometheus:go_default_library",
"//vendor/k8s.io/component-base/logs:go_default_library",
"//vendor/k8s.io/kubernetes/pkg/util/prometheusclientgo:go_default_library",
"//vendor/k8s.io/component-base/metrics/prometheus/clientgo:go_default_library",
"//vendor/k8s.io/legacy-cloud-providers/azure:go_default_library",
],
)
Expand Down
9 changes: 4 additions & 5 deletions cmd/cloud-controller-manager/app/controllermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ func NewCloudControllerManagerCommand() *cobra.Command {
}

cmd := &cobra.Command{
Use: "cloud-controller-manager",
Long: `The Cloud controller manager is a daemon that embeds
the cloud specific control loops shipped with Kubernetes.`,
Use: "cloud-controller-manager",
Long: `The Cloud controller manager is a daemon that embeds the cloud specific control loops shipped with Kubernetes.`,
Run: func(cmd *cobra.Command, args []string) {
verflag.PrintAndExitIfRequested()
verflag.PrintAndExitIfRequested("Cloud Provider Azure")
utilflag.PrintFlags(cmd.Flags())

c, err := s.Config(KnownControllers(), ControllersDisabledByDefault.List())
Expand Down Expand Up @@ -140,7 +139,7 @@ func Run(c *cloudcontrollerconfig.CompletedConfig, stopCh <-chan struct{}) error
}

// Setup any healthz checks we will want to use.
var checks []healthz.HealthzChecker
var checks []healthz.HealthChecker
var electionChecker *leaderelection.HealthzAdaptor
if c.ComponentConfig.Generic.LeaderElection.LeaderElect {
electionChecker = leaderelection.NewLeaderHealthzAdaptor(time.Second * 20)
Expand Down
3 changes: 1 addition & 2 deletions cmd/cloud-controller-manager/controller-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import (
"k8s.io/cloud-provider-azure/cmd/cloud-controller-manager/app"
"k8s.io/component-base/logs"

_ "k8s.io/cloud-provider-azure/pkg/version/prometheus" // for version metric registration
_ "k8s.io/kubernetes/pkg/util/prometheusclientgo" // load all the prometheus client-go plugins
_ "k8s.io/component-base/metrics/prometheus/clientgo" // load all the prometheus client-go plugins
_ "k8s.io/legacy-cloud-providers/azure"
)

Expand Down
20 changes: 20 additions & 0 deletions cmd/cloud-node-manager/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
name = "go_default_library",
srcs = ["node-manager.go"],
importpath = "k8s.io/cloud-provider-azure/cmd/cloud-node-manager",
visibility = ["//visibility:private"],
deps = [
"//cmd/cloud-node-manager/app:go_default_library",
"//vendor/k8s.io/component-base/logs:go_default_library",
"//vendor/k8s.io/component-base/metrics/prometheus/clientgo:go_default_library",
"//vendor/k8s.io/legacy-cloud-providers/azure:go_default_library",
],
)

go_binary(
name = "cloud-node-manager",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
)
26 changes: 26 additions & 0 deletions cmd/cloud-node-manager/app/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["nodemanager.go"],
importpath = "k8s.io/cloud-provider-azure/cmd/cloud-node-manager/app",
visibility = ["//visibility:public"],
deps = [
"//cmd/cloud-node-manager/app/config:go_default_library",
"//cmd/cloud-node-manager/app/options:go_default_library",
"//pkg/node:go_default_library",
"//pkg/nodemanager:go_default_library",
"//pkg/version:go_default_library",
"//pkg/version/verflag:go_default_library",
"//vendor/github.com/spf13/cobra:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/k8s.io/apiserver/pkg/server:go_default_library",
"//vendor/k8s.io/apiserver/pkg/server/healthz:go_default_library",
"//vendor/k8s.io/apiserver/pkg/util/term:go_default_library",
"//vendor/k8s.io/component-base/cli/flag:go_default_library",
"//vendor/k8s.io/component-base/cli/globalflag:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/kubernetes/cmd/controller-manager/app:go_default_library",
"//vendor/k8s.io/kubernetes/pkg/util/flag:go_default_library",
],
)
18 changes: 18 additions & 0 deletions cmd/cloud-node-manager/app/config/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["config.go"],
importpath = "k8s.io/cloud-provider-azure/cmd/cloud-node-manager/app/config",
visibility = ["//visibility:public"],
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apiserver/pkg/server:go_default_library",
"//vendor/k8s.io/client-go/informers:go_default_library",
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
"//vendor/k8s.io/client-go/tools/record:go_default_library",
"//vendor/k8s.io/component-base/config:go_default_library",
"//vendor/k8s.io/kubernetes/pkg/controller:go_default_library",
],
)
72 changes: 72 additions & 0 deletions cmd/cloud-node-manager/app/config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
Copyright 2019 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package app

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
apiserver "k8s.io/apiserver/pkg/server"
"k8s.io/client-go/informers"
clientset "k8s.io/client-go/kubernetes"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/record"
componentbaseconfig "k8s.io/component-base/config"
"k8s.io/kubernetes/pkg/controller"
)

// Config is the main context object for the cloud node manager.
type Config struct {
// the node name
NodeName string

// NodeStatusUpdateFrequency is the frequency at which the controller updates nodes' status
NodeStatusUpdateFrequency metav1.Duration

SecureServing *apiserver.SecureServingInfo
// LoopbackClientConfig is a config for a privileged loopback connection
LoopbackClientConfig *restclient.Config

// TODO: remove deprecated insecure serving
InsecureServing *apiserver.DeprecatedInsecureServingInfo
Authentication apiserver.AuthenticationInfo
Authorization apiserver.AuthorizationInfo

// the general kube client
Client *clientset.Clientset

// the rest config for the master
Kubeconfig *restclient.Config

// the event sink
EventRecorder record.EventRecorder

// ClientBuilder will provide a client for this controller to use
ClientBuilder controller.ControllerClientBuilder

// VersionedClient will provide a client for informers
VersionedClient clientset.Interface

// SharedInformers gives access to informers for the controller.
SharedInformers informers.SharedInformerFactory

// minResyncPeriod is the resync period in reflectors; will be random between
// minResyncPeriod and 2*minResyncPeriod.
MinResyncPeriod metav1.Duration

// ClientConnection specifies the kubeconfig file and client connection
// settings for the proxy server to use when communicating with the apiserver.
ClientConnection componentbaseconfig.ClientConnectionConfiguration
}
Loading