mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Add cert_dir option to kube-apiserver
This commit is contained in:
		@@ -25,6 +25,7 @@ import (
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"os"
 | 
			
		||||
	"regexp"
 | 
			
		||||
	"path"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
@@ -56,6 +57,7 @@ type APIServer struct {
 | 
			
		||||
	APIBurst                   int
 | 
			
		||||
	TLSCertFile                string
 | 
			
		||||
	TLSPrivateKeyFile          string
 | 
			
		||||
	CertDirectory              string
 | 
			
		||||
	APIPrefix                  string
 | 
			
		||||
	StorageVersion             string
 | 
			
		||||
	CloudProvider              string
 | 
			
		||||
@@ -99,6 +101,7 @@ func NewAPIServer() *APIServer {
 | 
			
		||||
		EnableLogsSupport:      true,
 | 
			
		||||
		MasterServiceNamespace: api.NamespaceDefault,
 | 
			
		||||
		ClusterName:            "kubernetes",
 | 
			
		||||
		CertDirectory:          "/var/run/kubernetes",
 | 
			
		||||
 | 
			
		||||
		RuntimeConfig: make(util.ConfigurationMap),
 | 
			
		||||
		KubeletConfig: client.KubeletConfig{
 | 
			
		||||
@@ -143,6 +146,7 @@ func (s *APIServer) AddFlags(fs *pflag.FlagSet) {
 | 
			
		||||
		"If HTTPS serving is enabled, and --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.")
 | 
			
		||||
	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.APIPrefix, "api_prefix", s.APIPrefix, "The prefix for API requests on the server. Default '/api'.")
 | 
			
		||||
	fs.StringVar(&s.StorageVersion, "storage_version", s.StorageVersion, "The version to store resources with. Defaults to server preferred")
 | 
			
		||||
	fs.StringVar(&s.CloudProvider, "cloud_provider", s.CloudProvider, "The provider for cloud services.  Empty string for no provider.")
 | 
			
		||||
@@ -368,8 +372,8 @@ func (s *APIServer) Run(_ []string) error {
 | 
			
		||||
			defer util.HandleCrash()
 | 
			
		||||
			for {
 | 
			
		||||
				if s.TLSCertFile == "" && s.TLSPrivateKeyFile == "" {
 | 
			
		||||
					s.TLSCertFile = "/var/run/kubernetes/apiserver.crt"
 | 
			
		||||
					s.TLSPrivateKeyFile = "/var/run/kubernetes/apiserver.key"
 | 
			
		||||
					s.TLSCertFile = path.Join(s.CertDirectory, "apiserver.crt")
 | 
			
		||||
					s.TLSPrivateKeyFile = path.Join(s.CertDirectory, "apiserver.key")
 | 
			
		||||
					if err := util.GenerateSelfSignedCert(config.PublicAddress.String(), s.TLSCertFile, s.TLSPrivateKeyFile); err != nil {
 | 
			
		||||
						glog.Errorf("Unable to generate self signed cert: %v", err)
 | 
			
		||||
					} else {
 | 
			
		||||
 
 | 
			
		||||
@@ -95,6 +95,7 @@ kube::log::status "Starting kube-apiserver"
 | 
			
		||||
  --public_address_override="127.0.0.1" \
 | 
			
		||||
  --kubelet_port=${KUBELET_PORT} \
 | 
			
		||||
  --runtime_config=api/v1beta3 \
 | 
			
		||||
  --cert_dir="${TMPDIR:-/tmp/}" \
 | 
			
		||||
  --portal_net="10.0.0.0/24" 1>&2 &
 | 
			
		||||
APISERVER_PID=$!
 | 
			
		||||
 | 
			
		||||
@@ -620,11 +621,11 @@ __EOF__
 | 
			
		||||
  ##################### 
 | 
			
		||||
 | 
			
		||||
  kube::log::status "Testing resource aliasing"
 | 
			
		||||
  kubectl create -f examples/cassandra/cassandra.yaml
 | 
			
		||||
  kubectl create -f examples/cassandra/cassandra-controller.yaml
 | 
			
		||||
  kubectl create -f examples/cassandra/cassandra-service.yaml
 | 
			
		||||
  kubectl create -f examples/cassandra/cassandra.yaml "${kube_flags[@]}"
 | 
			
		||||
  kubectl create -f examples/cassandra/cassandra-controller.yaml "${kube_flags[@]}"
 | 
			
		||||
  kubectl create -f examples/cassandra/cassandra-service.yaml "${kube_flags[@]}"
 | 
			
		||||
  kube::test::get_object_assert "all -l'name=cassandra'" "{{range.items}}{{$id_field}}:{{end}}" 'cassandra:cassandra:cassandra:'
 | 
			
		||||
  kubectl delete all -l name=cassandra
 | 
			
		||||
  kubectl delete all -l name=cassandra "${kube_flags[@]}"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  ###########
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user