-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[registry-facade] Support zero-downtime updates #2601
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright (c) 2020 Gitpod GmbH. All rights reserved. | ||
# Licensed under the MIT License. See License-MIT.txt in the project root for license information. | ||
|
||
{{ if .Values.installPodSecurityPolicies -}} | ||
kind: ClusterRole | ||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
metadata: | ||
name: {{ .Release.Namespace }}-ns-registry-facade | ||
labels: | ||
app: {{ template "gitpod.fullname" . }} | ||
component: cluster | ||
kind: clusterrole | ||
stage: {{ .Values.installation.stage }} | ||
rules: | ||
- apiGroups: ["policy"] | ||
resources: ["podsecuritypolicies"] | ||
verbs: ["use"] | ||
resourceNames: | ||
- {{ .Release.Namespace }}-ns-registry-facade | ||
{{- end -}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Copyright (c) 2020 Gitpod GmbH. All rights reserved. | ||
# Licensed under the MIT License. See License-MIT.txt in the project root for license information. | ||
|
||
{{ if .Values.installPodSecurityPolicies -}} | ||
# Taken from the examples here: | ||
# Examples: https://kubernetes.io/docs/concepts/policy/pod-security-policy/#example-policies | ||
# File: https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/policy/restricted-psp.yaml | ||
apiVersion: policy/v1beta1 | ||
kind: PodSecurityPolicy | ||
metadata: | ||
name: {{ .Release.Namespace }}-ns-registry-facade | ||
labels: | ||
app: {{ template "gitpod.fullname" . }} | ||
component: cluster | ||
kind: podsecuritypolicy | ||
stage: {{ .Values.installation.stage }} | ||
annotations: | ||
seccomp.security.alpha.kubernetes.io/allowedProfileNames: 'runtime/default' | ||
apparmor.security.beta.kubernetes.io/allowedProfileNames: 'runtime/default' | ||
seccomp.security.alpha.kubernetes.io/defaultProfileName: 'runtime/default' | ||
apparmor.security.beta.kubernetes.io/defaultProfileName: 'runtime/default' | ||
spec: | ||
##### | ||
# The nginx master process (currently?) runs as root, thus we have to turn some safe things off | ||
##### | ||
### TODO root proxy | ||
# privileged: false | ||
# # Required to prevent escalations to root. | ||
# allowPrivilegeEscalation: false | ||
# # This is redundant with non-root + disallow privilege escalation, | ||
# # but we can provide it for defense in depth. | ||
# requiredDropCapabilities: | ||
# - ALL | ||
### TODO root proxy | ||
# Allow core volume types. | ||
volumes: | ||
- 'configMap' | ||
- 'secret' | ||
- 'emptyDir' | ||
- 'hostPath' | ||
hostNetwork: true | ||
hostIPC: false | ||
hostPID: false | ||
hostPorts: | ||
- min: 30000 | ||
max: 33000 | ||
runAsUser: | ||
rule: 'RunAsAny' | ||
seLinux: | ||
# This policy assumes the nodes are using AppArmor rather than SELinux. | ||
rule: 'RunAsAny' | ||
supplementalGroups: | ||
rule: 'MustRunAs' | ||
ranges: | ||
# Forbid adding the root group. | ||
- min: 1 | ||
max: 65535 | ||
fsGroup: | ||
rule: 'MustRunAs' | ||
ranges: | ||
# Forbid adding the root group. | ||
- min: 1 | ||
max: 65535 | ||
readOnlyRootFilesystem: false | ||
{{- end -}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright (c) 2020 TypeFox GmbH. All rights reserved. | ||
// Licensed under the GNU Affero General Public License (AGPL). | ||
// See License-AGPL.txt in the project root for license information. | ||
|
||
package cmd | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
"time" | ||
|
||
"github.com/gitpod-io/gitpod/common-go/log" | ||
"github.com/gitpod-io/gitpod/registry-facade/pkg/registry" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// debugHandover represents the run command | ||
var debugHandover = &cobra.Command{ | ||
Use: "handover <socket-dir>", | ||
Short: "Attempts to get the listener socket from a registry-facade - and offers it back up for someone else", | ||
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) | ||
defer cancel() | ||
|
||
l, err := registry.ReceiveHandover(ctx, args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
if l == nil { | ||
log.Warn("received no listener") | ||
return nil | ||
} | ||
|
||
log.Info("handover successfull - holding listener for someone else") | ||
|
||
hoctx, cancelHO := context.WithCancel(context.Background()) | ||
defer cancelHO() | ||
|
||
ho, err := registry.OfferHandover(hoctx, args[0], l, nil) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
log.Info("waiting for someone else to handover to - stop with Ctrl+C") | ||
sigChan := make(chan os.Signal, 1) | ||
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM) | ||
|
||
select { | ||
case didHO := <-ho: | ||
if didHO { | ||
<-ho | ||
} | ||
case <-sigChan: | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(debugHandover) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.