-
Notifications
You must be signed in to change notification settings - Fork 303
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
Welcome defaultbackend to the ingress-gce repo #503
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b24ce4c
Welcome defaultbackend to the ingress-gce repo
6151f89
[404-server] Remove metrics and move files
jonpulsifer 4bb3afe
[404-server] build with the rest of the images
jonpulsifer 06d7cd3
[404-server] remove OWNERS from cmd/404-server
jonpulsifer 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 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,22 @@ | ||
# Copyright 2015 The Kubernetes Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
FROM scratch | ||
|
||
ADD bin/ARG_ARCH/ARG_BIN /ARG_BIN | ||
|
||
# nobody:nobody | ||
USER 65534:65534 | ||
|
||
ENTRYPOINT ["/ARG_BIN"] |
This file contains 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 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,12 @@ | ||
approvers: | ||
- bprashanth | ||
- luxas | ||
- mikedanese | ||
- aledbf | ||
- nicksardo | ||
reviewers: | ||
- bprashanth | ||
- luxas | ||
- mikedanese | ||
- aledbf | ||
- nicksardo |
This file contains 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,6 @@ | ||
# 404-server (default backend) | ||
|
||
404-server is a simple webserver that satisfies the ingress, which means it has to do two things: | ||
|
||
1. Serves a 404 page at `/` | ||
2. Serves a 200 at `/healthz` |
This file contains 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,97 @@ | ||
/* | ||
Copyright 2017 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// A webserver that only serves a 404 page. Used as a default backend. | ||
package main | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"fmt" | ||
"net/http" | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
"time" | ||
) | ||
|
||
func main() { | ||
// command line arguments | ||
port := flag.Int("port", 8080, "Port number to serve default backend 404 page.") | ||
timeout := flag.Duration("timeout", 5*time.Second, "Time in seconds to wait before forcefully terminating the server.") | ||
|
||
flag.Parse() | ||
|
||
notFound := newHTTPServer(fmt.Sprintf(":%d", *port), notFound()) | ||
|
||
// start the main http server | ||
go func() { | ||
err := notFound.ListenAndServe() | ||
if err != http.ErrServerClosed { | ||
fmt.Fprintf(os.Stderr, "could not start http server: %s\n", err) | ||
os.Exit(1) | ||
} | ||
}() | ||
|
||
waitShutdown(notFound, *timeout) | ||
} | ||
|
||
type server struct { | ||
mux *http.ServeMux | ||
} | ||
|
||
func (s *server) ServeHTTP(w http.ResponseWriter, r *http.Request) { | ||
s.mux.ServeHTTP(w, r) | ||
} | ||
|
||
func newHTTPServer(addr string, handler http.Handler) *http.Server { | ||
return &http.Server{ | ||
Addr: addr, | ||
Handler: handler, | ||
ReadTimeout: 10 * time.Second, | ||
ReadHeaderTimeout: 10 * time.Second, | ||
WriteTimeout: 10 * time.Second, | ||
IdleTimeout: 10 * time.Second, | ||
} | ||
} | ||
|
||
func notFound(options ...func(*server)) *server { | ||
s := &server{mux: http.NewServeMux()} | ||
// TODO: this handler exists only to avoid breaking existing deployments | ||
s.mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { | ||
w.WriteHeader(http.StatusOK) | ||
fmt.Fprint(w, "ok") | ||
}) | ||
s.mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | ||
w.WriteHeader(http.StatusNotFound) | ||
fmt.Fprint(w, "default backend - 404") | ||
}) | ||
return s | ||
} | ||
|
||
func waitShutdown(s *http.Server, timeout time.Duration) { | ||
stop := make(chan os.Signal, 1) | ||
signal.Notify(stop, os.Interrupt, syscall.SIGTERM) | ||
<-stop | ||
|
||
fmt.Fprintf(os.Stdout, "stopping http server...\n") | ||
ctx, cancel := context.WithTimeout(context.Background(), timeout) | ||
defer cancel() | ||
|
||
if err := s.Shutdown(ctx); err != nil { | ||
fmt.Fprintf(os.Stderr, "could not gracefully shutdown http server: %s\n", err) | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need a separate OWNERS for this. The top level OWNERS should suffice.