mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Fix test-cmd to work with the kubelet listening on HTTPS.
This commit is contained in:
parent
58bc792e68
commit
dd9ec46cc0
@ -23,6 +23,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -91,6 +92,7 @@ type KubeletServer struct {
|
|||||||
CloudConfigFile string
|
CloudConfigFile string
|
||||||
TLSCertFile string
|
TLSCertFile string
|
||||||
TLSPrivateKeyFile string
|
TLSPrivateKeyFile string
|
||||||
|
CertDirectory string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewKubeletServer will create a new KubeletServer with default values.
|
// NewKubeletServer will create a new KubeletServer with default values.
|
||||||
@ -118,6 +120,7 @@ func NewKubeletServer() *KubeletServer {
|
|||||||
ImageGCLowThresholdPercent: 80,
|
ImageGCLowThresholdPercent: 80,
|
||||||
NetworkPluginName: "",
|
NetworkPluginName: "",
|
||||||
HostNetworkSources: kubelet.FileSource,
|
HostNetworkSources: kubelet.FileSource,
|
||||||
|
CertDirectory: "/var/run/kubernetes",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,8 +137,9 @@ func (s *KubeletServer) AddFlags(fs *pflag.FlagSet) {
|
|||||||
fs.StringVar(&s.TLSCertFile, "tls_cert_file", s.TLSCertFile, ""+
|
fs.StringVar(&s.TLSCertFile, "tls_cert_file", s.TLSCertFile, ""+
|
||||||
"File containing x509 Certificate for HTTPS. (CA cert, if any, concatenated after server cert). "+
|
"File containing x509 Certificate for HTTPS. (CA cert, if any, concatenated after server cert). "+
|
||||||
"If --tls_cert_file and --tls_private_key_file are not provided, a self-signed certificate and key "+
|
"If --tls_cert_file and --tls_private_key_file are not provided, a self-signed certificate and key "+
|
||||||
"are generated for the public address and saved to /var/run/kubernetes.")
|
"are generated for the public address and saved to the directory passed to --cert_dir.")
|
||||||
fs.StringVar(&s.TLSPrivateKeyFile, "tls_private_key_file", s.TLSPrivateKeyFile, "File containing x509 private key matching --tls_cert_file.")
|
fs.StringVar(&s.TLSPrivateKeyFile, "tls_private_key_file", s.TLSPrivateKeyFile, "File containing x509 private key matching --tls_cert_file.")
|
||||||
|
fs.StringVar(&s.CertDirectory, "cert_dir", s.CertDirectory, "The directory where the TLS certs are located (by default /var/run/kubernetes)")
|
||||||
fs.StringVar(&s.HostnameOverride, "hostname_override", s.HostnameOverride, "If non-empty, will use this string as identification instead of the actual hostname.")
|
fs.StringVar(&s.HostnameOverride, "hostname_override", s.HostnameOverride, "If non-empty, will use this string as identification instead of the actual hostname.")
|
||||||
fs.StringVar(&s.PodInfraContainerImage, "pod_infra_container_image", s.PodInfraContainerImage, "The image whose network/ipc namespaces containers in each pod will use.")
|
fs.StringVar(&s.PodInfraContainerImage, "pod_infra_container_image", s.PodInfraContainerImage, "The image whose network/ipc namespaces containers in each pod will use.")
|
||||||
fs.StringVar(&s.DockerEndpoint, "docker_endpoint", s.DockerEndpoint, "If non-empty, use this for the docker endpoint to communicate with")
|
fs.StringVar(&s.DockerEndpoint, "docker_endpoint", s.DockerEndpoint, "If non-empty, use this for the docker endpoint to communicate with")
|
||||||
@ -204,8 +208,8 @@ func (s *KubeletServer) Run(_ []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if s.TLSCertFile == "" && s.TLSPrivateKeyFile == "" {
|
if s.TLSCertFile == "" && s.TLSPrivateKeyFile == "" {
|
||||||
s.TLSCertFile = "/var/run/kubernetes/kubelet.crt"
|
s.TLSCertFile = path.Join(s.CertDirectory, "kubelet.crt")
|
||||||
s.TLSPrivateKeyFile = "/var/run/kubernetes/kubelet.key"
|
s.TLSPrivateKeyFile = path.Join(s.CertDirectory, "kubelet.key")
|
||||||
if err := util.GenerateSelfSignedCert(util.GetHostname(s.HostnameOverride), s.TLSCertFile, s.TLSPrivateKeyFile); err != nil {
|
if err := util.GenerateSelfSignedCert(util.GetHostname(s.HostnameOverride), s.TLSCertFile, s.TLSPrivateKeyFile); err != nil {
|
||||||
glog.Fatalf("Unable to generate self signed cert: %v", err)
|
glog.Fatalf("Unable to generate self signed cert: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ ETCD_PORT=${ETCD_PORT:-4001}
|
|||||||
API_PORT=${API_PORT:-8080}
|
API_PORT=${API_PORT:-8080}
|
||||||
API_HOST=${API_HOST:-127.0.0.1}
|
API_HOST=${API_HOST:-127.0.0.1}
|
||||||
KUBELET_PORT=${KUBELET_PORT:-10250}
|
KUBELET_PORT=${KUBELET_PORT:-10250}
|
||||||
|
KUBELET_HEALTHZ_PORT=${KUBELET_HEALTHZ_PORT:-10248}
|
||||||
CTLRMGR_PORT=${CTLRMGR_PORT:-10252}
|
CTLRMGR_PORT=${CTLRMGR_PORT:-10252}
|
||||||
|
|
||||||
# Check kubectl
|
# Check kubectl
|
||||||
@ -58,27 +59,31 @@ kube::log::status "Starting kubelet in masterless mode"
|
|||||||
"${KUBE_OUTPUT_HOSTBIN}/kubelet" \
|
"${KUBE_OUTPUT_HOSTBIN}/kubelet" \
|
||||||
--really_crash_for_testing=true \
|
--really_crash_for_testing=true \
|
||||||
--root_dir=/tmp/kubelet.$$ \
|
--root_dir=/tmp/kubelet.$$ \
|
||||||
|
--cert_dir="${TMPDIR:-/tmp/}" \
|
||||||
--docker_endpoint="fake://" \
|
--docker_endpoint="fake://" \
|
||||||
--hostname_override="127.0.0.1" \
|
--hostname_override="127.0.0.1" \
|
||||||
--address="127.0.0.1" \
|
--address="127.0.0.1" \
|
||||||
--port="$KUBELET_PORT" 1>&2 &
|
--port="$KUBELET_PORT" \
|
||||||
|
--healthz_port="${KUBELET_HEALTHZ_PORT}" 1>&2 &
|
||||||
KUBELET_PID=$!
|
KUBELET_PID=$!
|
||||||
kube::util::wait_for_url "http://127.0.0.1:${KUBELET_PORT}/healthz" "kubelet: "
|
kube::util::wait_for_url "http://127.0.0.1:${KUBELET_HEALTHZ_PORT}/healthz" "kubelet: "
|
||||||
kill ${KUBELET_PID} 1>&2 2>/dev/null
|
kill ${KUBELET_PID} 1>&2 2>/dev/null
|
||||||
|
|
||||||
kube::log::status "Starting kubelet in masterful mode"
|
kube::log::status "Starting kubelet in masterful mode"
|
||||||
"${KUBE_OUTPUT_HOSTBIN}/kubelet" \
|
"${KUBE_OUTPUT_HOSTBIN}/kubelet" \
|
||||||
--really_crash_for_testing=true \
|
--really_crash_for_testing=true \
|
||||||
--root_dir=/tmp/kubelet.$$ \
|
--root_dir=/tmp/kubelet.$$ \
|
||||||
|
--cert_dir="${TMPDIR:-/tmp/}" \
|
||||||
--docker_endpoint="fake://" \
|
--docker_endpoint="fake://" \
|
||||||
--hostname_override="127.0.0.1" \
|
--hostname_override="127.0.0.1" \
|
||||||
--address="127.0.0.1" \
|
--address="127.0.0.1" \
|
||||||
--api_servers="${API_HOST}:${API_PORT}" \
|
--api_servers="${API_HOST}:${API_PORT}" \
|
||||||
--auth_path="${KUBE_ROOT}/hack/.test-cmd-auth" \
|
--auth_path="${KUBE_ROOT}/hack/.test-cmd-auth" \
|
||||||
--port="$KUBELET_PORT" 1>&2 &
|
--port="$KUBELET_PORT" \
|
||||||
|
--healthz_port="${KUBELET_HEALTHZ_PORT}" 1>&2 &
|
||||||
KUBELET_PID=$!
|
KUBELET_PID=$!
|
||||||
|
|
||||||
kube::util::wait_for_url "http://127.0.0.1:${KUBELET_PORT}/healthz" "kubelet: "
|
kube::util::wait_for_url "http://127.0.0.1:${KUBELET_HEALTHZ_PORT}/healthz" "kubelet: "
|
||||||
|
|
||||||
# Start kube-apiserver
|
# Start kube-apiserver
|
||||||
kube::log::status "Starting kube-apiserver"
|
kube::log::status "Starting kube-apiserver"
|
||||||
|
Loading…
Reference in New Issue
Block a user