Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
xigang committed Apr 1, 2020
2 parents 6d836d0 + abb0183 commit 3667a7f
Show file tree
Hide file tree
Showing 298 changed files with 7,111 additions and 2,485 deletions.
420 changes: 210 additions & 210 deletions Godeps/LICENSES

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions api/openapi-spec/swagger.json

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

2 changes: 1 addition & 1 deletion build/README.md
Expand Up @@ -34,7 +34,7 @@ The following scripts are found in the [`build/`](.) directory. Note that all sc

## Basic Flow

The scripts directly under [`build/`](.) are used to build and test. They will ensure that the `kube-build` Docker image is built (based on [`build/build-image/Dockerfile`](build-image/Dockerfile)) and then execute the appropriate command in that container. These scripts will both ensure that the right data is cached from run to run for incremental builds and will copy the results back out of the container.
The scripts directly under [`build/`](.) are used to build and test. They will ensure that the `kube-build` Docker image is built (based on [`build/build-image/Dockerfile`](build-image/Dockerfile) and after base image's `KUBE_BUILD_IMAGE_CROSS_TAG` from Dockerfile is replaced with one of those actual tags of the base image, like `v1.13.9-2`) and then execute the appropriate command in that container. These scripts will both ensure that the right data is cached from run to run for incremental builds and will copy the results back out of the container.

The `kube-build` container image is built by first creating a "context" directory in `_output/images/build-image`. It is done there instead of at the root of the Kubernetes repo to minimize the amount of data we need to package up when building the image.

Expand Down
4 changes: 2 additions & 2 deletions build/lib/release.sh
Expand Up @@ -439,7 +439,7 @@ function kube::release::package_kube_manifests_tarball() {
cp "${KUBE_ROOT}/cluster/gce/gci/health-monitor.sh" "${dst_dir}/health-monitor.sh"
# Merge GCE-specific addons with general purpose addons.
for d in cluster/addons cluster/gce/addons; do
find "${KUBE_ROOT}/${d}" \( \( -name \*.yaml -o -name \*.yaml.in -o -name \*.json \) -a ! \( -name \*demo\* \) \) -print0 | tar c --transform "s|${KUBE_ROOT#/*}/${d}||" --null -T - | "${TAR}" x -C "${dst_dir}"
find "${KUBE_ROOT}/${d}" \( \( -name \*.yaml -o -name \*.yaml.in -o -name \*.json \) -a ! \( -name \*demo\* \) \) -print0 | "${TAR}" c --transform "s|${KUBE_ROOT#/*}/${d}||" --null -T - | "${TAR}" x -C "${dst_dir}"
done

kube::release::clean_cruft
Expand Down Expand Up @@ -505,7 +505,7 @@ function kube::release::package_test_tarballs() {
# the portable test tarball.
mkdir -p "${release_stage}/test/images"
cp -fR "${KUBE_ROOT}/test/images" "${release_stage}/test/"
tar c "${KUBE_TEST_PORTABLE[@]}" | tar x -C "${release_stage}"
"${TAR}" c "${KUBE_TEST_PORTABLE[@]}" | "${TAR}" x -C "${release_stage}"

kube::release::clean_cruft

Expand Down
2 changes: 1 addition & 1 deletion cluster/gce/config-common.sh
Expand Up @@ -159,4 +159,4 @@ export WINDOWS_BOOTSTRAP_KUBECONFIG_FILE="${WINDOWS_K8S_DIR}\kubelet.bootstrap-k
# Path for kube-proxy kubeconfig file on Windows nodes.
export WINDOWS_KUBEPROXY_KUBECONFIG_FILE="${WINDOWS_K8S_DIR}\kubeproxy.kubeconfig"
# Pause container image for Windows container.
export WINDOWS_INFRA_CONTAINER="gcr.io/gke-release/pause-win:1.1.0"
export WINDOWS_INFRA_CONTAINER="gcr.io/gke-release/pause-win:1.2.1"
3 changes: 0 additions & 3 deletions cluster/gce/gci/configure-helper.sh
Expand Up @@ -445,9 +445,6 @@ function mount-master-pd {
mkdir -p "${mount_point}/srv/sshproxy"
ln -s -f "${mount_point}/srv/sshproxy" /etc/srv/sshproxy

if ! id etcd &>/dev/null; then
useradd -s /sbin/nologin -d /var/etcd etcd
fi
chown -R etcd "${mount_point}/var/etcd"
chgrp -R etcd "${mount_point}/var/etcd"
}
Expand Down
6 changes: 6 additions & 0 deletions cluster/gce/gci/master.yaml
@@ -1,5 +1,11 @@
#cloud-config

users:
- name: etcd
homedir: /var/etcd
lock_passwd: true
ssh_redirect_user: true

write_files:
- path: /etc/systemd/system/kube-master-installation.service
permissions: 0644
Expand Down
5 changes: 5 additions & 0 deletions cluster/gce/list-resources.sh
Expand Up @@ -75,6 +75,9 @@ echo "Provider: ${KUBERNETES_PROVIDER:-}"

# List resources related to instances, filtering by the instance prefix if
# provided.

set +e # do not stop on error

gcloud-list compute instance-templates "name ~ '${INSTANCE_PREFIX}.*'"
gcloud-list compute instance-groups "${ZONE:+"zone:(${ZONE}) AND "}name ~ '${INSTANCE_PREFIX}.*'"
gcloud-list compute instances "${ZONE:+"zone:(${ZONE}) AND "}name ~ '${INSTANCE_PREFIX}.*'"
Expand All @@ -95,3 +98,5 @@ gcloud-list compute forwarding-rules ${REGION:+"region=(${REGION})"}
gcloud-list compute target-pools ${REGION:+"region=(${REGION})"}

gcloud-list logging sinks

set -e
6 changes: 3 additions & 3 deletions cluster/gce/util.sh
Expand Up @@ -88,11 +88,11 @@ function set-linux-node-image() {
function set-windows-node-image() {
WINDOWS_NODE_IMAGE_PROJECT="windows-cloud"
if [[ "${WINDOWS_NODE_OS_DISTRIBUTION}" == "win2019" ]]; then
WINDOWS_NODE_IMAGE="windows-server-2019-dc-core-for-containers-v20200114"
WINDOWS_NODE_IMAGE="windows-server-2019-dc-core-for-containers-v20200310"
elif [[ "${WINDOWS_NODE_OS_DISTRIBUTION}" == "win1909" ]]; then
WINDOWS_NODE_IMAGE="windows-server-1909-dc-core-for-containers-v20200114"
WINDOWS_NODE_IMAGE="windows-server-1909-dc-core-for-containers-v20200310"
elif [[ "${WINDOWS_NODE_OS_DISTRIBUTION}" == "win1809" ]]; then
WINDOWS_NODE_IMAGE="windows-server-1809-dc-core-for-containers-v20200114"
WINDOWS_NODE_IMAGE="windows-server-1809-dc-core-for-containers-v20200310"
else
echo "Unknown WINDOWS_NODE_OS_DISTRIBUTION ${WINDOWS_NODE_OS_DISTRIBUTION}" >&2
exit 1
Expand Down
27 changes: 20 additions & 7 deletions cluster/gce/windows/k8s-node-setup.psm1
Expand Up @@ -135,11 +135,24 @@ function Add_GceMetadataServerRoute {
}
}

# Returns a PowerShell object representing the Windows version.
function Get_WindowsVersion {
# Unlike checking `[System.Environment]::OSVersion.Version`, this long-winded
# approach gets the OS revision/patch number correctly
# (https://superuser.com/a/1160428/652018).
$win_ver = New-Object -TypeName PSObject
$win_ver | Add-Member -MemberType NoteProperty -Name Major -Value $(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' CurrentMajorVersionNumber).CurrentMajorVersionNumber
$win_ver | Add-Member -MemberType NoteProperty -Name Minor -Value $(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' CurrentMinorVersionNumber).CurrentMinorVersionNumber
$win_ver | Add-Member -MemberType NoteProperty -Name Build -Value $(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' CurrentBuild).CurrentBuild
$win_ver | Add-Member -MemberType NoteProperty -Name Revision -Value $(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' UBR).UBR
return $win_ver
}

# Writes debugging information, such as Windows version and patch info, to the
# console.
function Dump-DebugInfoToConsole {
Try {
$version = "$([System.Environment]::OSVersion.Version | Out-String)"
$version = Get_WindowsVersion | Out-String
$hotfixes = "$(Get-Hotfix | Out-String)"
$image = "$(Get-InstanceMetadata 'image' | Out-String)"
Log-Output "Windows version:`n$version"
Expand Down Expand Up @@ -1115,7 +1128,7 @@ function Start-WorkerServices {
$kubelet_args = $kubelet_args_str.Split(" ")
Log-Output "kubelet_args from metadata: ${kubelet_args}"
$default_kubelet_args = @(`
"--pod-infra-container-image=${INFRA_CONTAINER}"
"--pod-infra-container-image=${env:INFRA_CONTAINER}"
)
$kubelet_args = ${default_kubelet_args} + ${kubelet_args}
if (-not (Test-NodeUsesAuthPlugin ${kube_env})) {
Expand Down Expand Up @@ -1253,14 +1266,14 @@ function Configure-Crictl {
# node startup steps!
# Pull-InfraContainer must be called AFTER Verify-WorkerServices.
function Pull-InfraContainer {
$name, $label = $INFRA_CONTAINER -split ':',2
$name, $label = ${env:INFRA_CONTAINER} -split ':',2
if (-not ("$(& crictl images)" -match "$name.*$label")) {
& crictl pull $INFRA_CONTAINER
& crictl pull ${env:INFRA_CONTAINER}
if (!$?) {
throw "Error running 'crictl pull $INFRA_CONTAINER'"
throw "Error running 'crictl pull ${env:INFRA_CONTAINER}'"
}
}
$inspect = "$(& crictl inspecti $INFRA_CONTAINER | Out-String)"
$inspect = "$(& crictl inspecti ${env:INFRA_CONTAINER} | Out-String)"
Log-Output "Infra/pause container:`n$inspect"
}

Expand Down Expand Up @@ -1473,7 +1486,7 @@ function Configure_Containerd {
[plugins.cri.cni]
bin_dir = 'CNI_BIN_DIR'
conf_dir = 'CNI_CONF_DIR'
"@.replace('INFRA_CONTAINER_IMAGE', $INFRA_CONTAINER).`
"@.replace('INFRA_CONTAINER_IMAGE', ${env:INFRA_CONTAINER}).`
replace('CNI_BIN_DIR', ${env:CNI_DIR}).`
replace('CNI_CONF_DIR', ${env:CNI_CONFIG_DIR})
}
Expand Down
2 changes: 1 addition & 1 deletion cluster/gce/windows/smoke-test.sh
Expand Up @@ -358,7 +358,7 @@ spec:
spec:
containers:
- name: pause-win
image: gcr.io/gke-release/pause-win:1.1.0
image: gcr.io/gke-release/pause-win:1.2.0
nodeSelector:
kubernetes.io/os: windows
tolerations:
Expand Down
2 changes: 1 addition & 1 deletion cluster/images/etcd-version-monitor/BUILD
Expand Up @@ -17,9 +17,9 @@ go_library(
importpath = "k8s.io/kubernetes/cluster/images/etcd-version-monitor",
deps = [
"//staging/src/k8s.io/component-base/metrics:go_default_library",
"//staging/src/k8s.io/component-base/metrics/testutil:go_default_library",
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
"//vendor/github.com/prometheus/client_model/go:go_default_library",
"//vendor/github.com/prometheus/common/expfmt:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
Expand Down
6 changes: 2 additions & 4 deletions cluster/images/etcd-version-monitor/etcd-version-monitor.go
Expand Up @@ -27,10 +27,10 @@ import (

"github.com/gogo/protobuf/proto"
dto "github.com/prometheus/client_model/go"
"github.com/prometheus/common/expfmt"
"github.com/spf13/pflag"

"k8s.io/component-base/metrics"
"k8s.io/component-base/metrics/testutil"
"k8s.io/klog"
)

Expand Down Expand Up @@ -271,9 +271,7 @@ func scrapeMetrics() (map[string]*dto.MetricFamily, error) {
}
defer resp.Body.Close()

// Parse the metrics in text format to a MetricFamily struct.
var textParser expfmt.TextParser
return textParser.TextToMetricFamilies(resp.Body)
return testutil.TextToMetricFamilies(resp.Body)
}

func renameMetric(mf *dto.MetricFamily, name string) {
Expand Down
5 changes: 4 additions & 1 deletion cluster/log-dump/log-dump.sh
Expand Up @@ -51,9 +51,10 @@ readonly kern_logfile="kern.log"
readonly initd_logfiles="docker/log"
readonly supervisord_logfiles="kubelet.log supervisor/supervisord.log supervisor/kubelet-stdout.log supervisor/kubelet-stderr.log supervisor/docker-stdout.log supervisor/docker-stderr.log"
readonly systemd_services="kubelet kubelet-monitor kube-container-runtime-monitor ${LOG_DUMP_SYSTEMD_SERVICES:-docker}"
readonly extra_log_files="${LOG_DUMP_EXTRA_FILES:-}"
readonly dump_systemd_journal="${LOG_DUMP_SYSTEMD_JOURNAL:-false}"
# Log files found in WINDOWS_LOGS_DIR on Windows nodes:
readonly windows_node_logfiles="kubelet.log kube-proxy.log docker.log"
readonly windows_node_logfiles="kubelet.log kube-proxy.log docker.log docker_images.log"
# Log files found in other directories on Windows nodes:
readonly windows_node_otherfiles="C:\\Windows\\MEMORY.dmp"

Expand Down Expand Up @@ -140,6 +141,7 @@ function save-logs() {
local opt_systemd_services="${4:-""}"
local on_master="${5:-"false"}"

files="${files} ${extra_log_files}"
if [[ -n "${use_custom_instance_list}" ]]; then
if [[ -n "${LOG_DUMP_SAVE_LOGS:-}" ]]; then
files="${files} ${LOG_DUMP_SAVE_LOGS:-}"
Expand Down Expand Up @@ -496,6 +498,7 @@ function dump_nodes_with_logexporter() {
sed -i'' -e "s@{{.GCSPath}}@${gcs_artifacts_dir}@g" "${KUBE_ROOT}/cluster/log-dump/logexporter-daemonset.yaml"
sed -i'' -e "s@{{.EnableHollowNodeLogs}}@${enable_hollow_node_logs}@g" "${KUBE_ROOT}/cluster/log-dump/logexporter-daemonset.yaml"
sed -i'' -e "s@{{.DumpSystemdJournal}}@${dump_systemd_journal}@g" "${KUBE_ROOT}/cluster/log-dump/logexporter-daemonset.yaml"
sed -i'' -e "s@{{.ExtraLogFiles}}@${extra_log_files}@g" "${KUBE_ROOT}/cluster/log-dump/logexporter-daemonset.yaml"

# Create the logexporter namespace, service-account secret and the logexporter daemonset within that namespace.
KUBECTL="${KUBE_ROOT}/cluster/kubectl.sh"
Expand Down
3 changes: 2 additions & 1 deletion cluster/log-dump/logexporter-daemonset.yaml
Expand Up @@ -36,7 +36,7 @@ spec:
spec:
containers:
- name: logexporter-test
image: gcr.io/k8s-testimages/logexporter:v20200227-da16e1b17
image: gcr.io/k8s-testimages/logexporter:v20200327-9ba073aa98
env:
- name: NODE_NAME
valueFrom:
Expand All @@ -50,6 +50,7 @@ spec:
- --gcloud-auth-file-path=/etc/service-account/service-account.json
- --enable-hollow-node-logs={{.EnableHollowNodeLogs}}
- --dump-systemd-journal={{.DumpSystemdJournal}}
- --extra-log-files={{.ExtraLogFiles}}
- --sleep-duration=24h
volumeMounts:
- mountPath: /etc/service-account
Expand Down
1 change: 1 addition & 0 deletions cmd/kube-apiserver/app/options/options_test.go
Expand Up @@ -159,6 +159,7 @@ func TestAddFlags(t *testing.T) {
Prefix: "/registry",
CompactionInterval: storagebackend.DefaultCompactInterval,
CountMetricPollPeriod: time.Minute,
DBMetricPollInterval: storagebackend.DefaultDBMetricPollInterval,
},
DefaultStorageMediaType: "application/vnd.kubernetes.protobuf",
DeleteCollectionWorkers: 1,
Expand Down
79 changes: 55 additions & 24 deletions cmd/kube-proxy/app/server.go
Expand Up @@ -576,6 +576,57 @@ func createClients(config componentbaseconfig.ClientConnectionConfiguration, mas
return client, eventClient.CoreV1(), nil
}

func serveHealthz(hz healthcheck.ProxierHealthUpdater) {
if hz == nil {
return
}

fn := func() {
err := hz.Run()
if err != nil {
// For historical reasons we do not abort on errors here. We may
// change that in the future.
klog.Errorf("healthz server failed: %v", err)
} else {
klog.Errorf("healthz server returned without error")
}
}
go wait.Until(fn, 5*time.Second, wait.NeverStop)
}

func serveMetrics(bindAddress string, proxyMode string, enableProfiling bool) {
if len(bindAddress) == 0 {
return
}

proxyMux := mux.NewPathRecorderMux("kube-proxy")
healthz.InstallHandler(proxyMux)
proxyMux.HandleFunc("/proxyMode", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.Header().Set("X-Content-Type-Options", "nosniff")
fmt.Fprintf(w, "%s", proxyMode)
})

//lint:ignore SA1019 See the Metrics Stability Migration KEP
proxyMux.Handle("/metrics", legacyregistry.Handler())

if enableProfiling {
routes.Profiling{}.Install(proxyMux)
}

configz.InstallHandler(proxyMux)

fn := func() {
err := http.ListenAndServe(bindAddress, proxyMux)
if err != nil {
// For historical reasons we do not abort on errors here. We may
// change that in the future.
utilruntime.HandleError(fmt.Errorf("starting metrics server failed: %v", err))
}
}
go wait.Until(fn, 5*time.Second, wait.NeverStop)
}

// Run runs the specified ProxyServer. This should never exit (unless CleanupAndExit is set).
// TODO: At the moment, Run() cannot return a nil error, otherwise it's caller will never exit. Update callers of Run to handle nil errors.
func (s *ProxyServer) Run() error {
Expand All @@ -595,33 +646,13 @@ func (s *ProxyServer) Run() error {
s.Broadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: s.EventClient.Events("")})
}

// TODO(thockin): make it possible for healthz and metrics to be on the same port.

// Start up a healthz server if requested
if s.HealthzServer != nil {
s.HealthzServer.Run()
}
serveHealthz(s.HealthzServer)

// Start up a metrics server if requested
if len(s.MetricsBindAddress) > 0 {
proxyMux := mux.NewPathRecorderMux("kube-proxy")
healthz.InstallHandler(proxyMux)
proxyMux.HandleFunc("/proxyMode", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.Header().Set("X-Content-Type-Options", "nosniff")
fmt.Fprintf(w, "%s", s.ProxyMode)
})
//lint:ignore SA1019 See the Metrics Stability Migration KEP
proxyMux.Handle("/metrics", legacyregistry.Handler())
if s.EnableProfiling {
routes.Profiling{}.Install(proxyMux)
}
configz.InstallHandler(proxyMux)
go wait.Until(func() {
err := http.ListenAndServe(s.MetricsBindAddress, proxyMux)
if err != nil {
utilruntime.HandleError(fmt.Errorf("starting metrics server failed: %v", err))
}
}, 5*time.Second, wait.NeverStop)
}
serveMetrics(s.MetricsBindAddress, s.ProxyMode, s.EnableProfiling)

// Tune conntrack, if requested
// Conntracker is always nil for windows
Expand Down
1 change: 1 addition & 0 deletions cmd/kubeadm/app/apis/output/register.go
Expand Up @@ -48,6 +48,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&BootstrapToken{},
&Images{},
&UpgradePlan{},
)
return nil
}
17 changes: 17 additions & 0 deletions cmd/kubeadm/app/apis/output/types.go
Expand Up @@ -40,3 +40,20 @@ type Images struct {

Images []string
}

// ComponentUpgradePlan represents information about upgrade plan for one component
type ComponentUpgradePlan struct {
Name string
CurrentVersion string
NewVersion string
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// UpgradePlan represents information about upgrade plan for the output
// produced by 'kubeadm upgrade plan'
type UpgradePlan struct {
metav1.TypeMeta

Components []ComponentUpgradePlan
}
1 change: 1 addition & 0 deletions cmd/kubeadm/app/apis/output/v1alpha1/register.go
Expand Up @@ -60,6 +60,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&BootstrapToken{},
&Images{},
&UpgradePlan{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
Expand Down

0 comments on commit 3667a7f

Please sign in to comment.