Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Documentation/install/upgrade.rst
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,17 @@ Annotations:

.. _1.7_required_changes:

IMPORTANT: Changes required before upgrading to 1.7.1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. warning::

Do not upgrade to 1.7.1 before reading the following sections and completing
the required steps for both 1.7.0 and 1.7.1.

* ``api-server-port``: This flag, available in cilium-operator deployment only,
changed its behavior. The old behavior was opening that port on all interfaces,
the new behavior is opening that port on ``127.0.0.1`` and ``::1`` only.

IMPORTANT: Changes required before upgrading to 1.7.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ spec:
{{- end }}
livenessProbe:
httpGet:
{{- if .Values.global.ipv4.enabled }}
host: '127.0.0.1'
{{- else }}
host: '[::1]'
{{- end }}
path: /healthz
port: 9234
scheme: HTTP
Expand Down
29 changes: 15 additions & 14 deletions install/kubernetes/quick-install.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
---
# Source: cilium/charts/agent/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: cilium
namespace: kube-system
---
# Source: cilium/charts/operator/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: cilium-operator
namespace: kube-system
---
# Source: cilium/charts/config/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
Expand Down Expand Up @@ -127,20 +141,6 @@ data:
enable-well-known-identities: "false"
enable-remote-node-identity: "true"
---
# Source: cilium/charts/agent/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: cilium
namespace: kube-system
---
# Source: cilium/charts/operator/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: cilium-operator
namespace: kube-system
---
# Source: cilium/charts/agent/templates/clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down Expand Up @@ -637,6 +637,7 @@ spec:
name: cilium-operator
livenessProbe:
httpGet:
host: '127.0.0.1'
path: /healthz
port: 9234
scheme: HTTP
Expand Down
48 changes: 38 additions & 10 deletions operator/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ import (
)

// startServer starts an api server listening on the given address.
func startServer(addr string, shutdownSignal <-chan struct{}, allSystemsGo <-chan struct{}) {
log.Infof("Starting apiserver on address %s", addr)

func startServer(shutdownSignal <-chan struct{}, allSystemsGo <-chan struct{}, addrs ...string) {
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
select {
// only start serving the real health check once all systems all up and running
Expand All @@ -37,16 +35,46 @@ func startServer(addr string, shutdownSignal <-chan struct{}, allSystemsGo <-cha
}
})

srv := &http.Server{Addr: addr}
errs := make(chan error, 1)
nServers := 0

go func() {
<-shutdownSignal
if err := srv.Shutdown(context.Background()); err != nil {
log.WithError(err).Error("apiserver shutdown")
// Since we are opening this on localhost only, we need to make sure
// we can open for both v4 and v6 localhost. In case the user is running
// v4-only or v6-only.
for _, addr := range addrs {
if addr == "" {
continue
}
}()
nServers++
srv := &http.Server{Addr: addr}
errCh := make(chan error, 1)

go func() {
err := srv.ListenAndServe()
if err != nil {
errCh <- err
errs <- err
}
}()
go func() {
select {
case <-shutdownSignal:
if err := srv.Shutdown(context.Background()); err != nil {
log.WithError(err).Error("apiserver shutdown")
}
case err := <-errCh:
log.Warnf("Unable to start status api: %s", err)
}
}()
log.Infof("Starting apiserver on address %s", addr)
}

log.Fatalf("Unable to start status api: %s", srv.ListenAndServe())
for err := range errs {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this race with errs <- err? If ListenAndServe fails slow enough, we would have exited this loop. Since it's fatal anyway, we could just put it instead of errs <- err (unless you wanted to print an error for each ListenAndServer failure, but this loop also races with line 65 I think).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nevermind. startServer is not expected to return.

nServers--
if nServers == 0 {
log.Fatalf("Unable to start status api: %s", err)
}
}
}

func healthHandlerOK(w http.ResponseWriter, r *http.Request) {
Expand Down
6 changes: 5 additions & 1 deletion operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ func kvstoreEnabled() bool {
synchronizeNodes
}

func getAPIServerAddr() []string {
return []string{fmt.Sprintf("127.0.0.1:%d", apiServerPort), fmt.Sprintf("[::1]:%d", apiServerPort)}
}

func runOperator(cmd *cobra.Command) {
logging.SetupLogging([]string{}, map[string]string{}, "cilium-operator", viper.GetBool("debug"))

Expand All @@ -222,7 +226,7 @@ func runOperator(cmd *cobra.Command) {

log.Infof("Cilium Operator %s", version.Version)
k8sInitDone := make(chan struct{})
go startServer(fmt.Sprintf(":%d", apiServerPort), shutdownSignal, k8sInitDone)
go startServer(shutdownSignal, k8sInitDone, getAPIServerAddr()...)

if enableMetrics {
registerMetrics()
Expand Down