forked from kubernetes/kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add control over container entrypoint
- Loading branch information
Showing
23 changed files
with
815 additions
and
226 deletions.
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,20 @@ | ||
# Copyright 2015 Google Inc. 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 ep ep | ||
ADD ep ep-2 | ||
EXPOSE 8080 | ||
ENTRYPOINT ["/ep"] | ||
CMD ["default", "arguments"] |
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,15 @@ | ||
all: push | ||
|
||
TAG = 0.1 | ||
|
||
ep: ep.go | ||
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-w' ./ep.go | ||
|
||
image: ep | ||
sudo docker build -t kubernetes/eptest:$(TAG) . | ||
|
||
push: image | ||
sudo docker push kubernetes/eptest:$(TAG) | ||
|
||
clean: | ||
rm -f ep |
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,29 @@ | ||
/* | ||
Copyright 2015 Google Inc. 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. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
// This program prints the arguments it's passed and exits. | ||
func main() { | ||
args := os.Args | ||
fmt.Printf("%v\n", args) | ||
os.Exit(0) | ||
} |
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
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
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
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
This file was deleted.
Oops, something went wrong.
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,59 @@ | ||
/* | ||
Copyright 2015 Google Inc. 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. | ||
*/ | ||
|
||
package container | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" | ||
) | ||
|
||
// GenerateContainerRef returns an *api.ObjectReference which references the given container | ||
// within the given pod. Returns an error if the reference can't be constructed or the | ||
// container doesn't actually belong to the pod. | ||
// | ||
// This function will return an error if the provided Pod does not have a selfLink, | ||
// but we expect selfLink to be populated at all call sites for the function. | ||
func GenerateContainerRef(pod *api.Pod, container *api.Container) (*api.ObjectReference, error) { | ||
fieldPath, err := fieldPath(pod, container) | ||
if err != nil { | ||
// TODO: figure out intelligent way to refer to containers that we implicitly | ||
// start (like the pod infra container). This is not a good way, ugh. | ||
fieldPath = "implicitly required container " + container.Name | ||
} | ||
ref, err := api.GetPartialReference(pod, fieldPath) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return ref, nil | ||
} | ||
|
||
// fieldPath returns a fieldPath locating container within pod. | ||
// Returns an error if the container isn't part of the pod. | ||
func fieldPath(pod *api.Pod, container *api.Container) (string, error) { | ||
for i := range pod.Spec.Containers { | ||
here := &pod.Spec.Containers[i] | ||
if here.Name == container.Name { | ||
if here.Name == "" { | ||
return fmt.Sprintf("spec.containers[%d]", i), nil | ||
} else { | ||
return fmt.Sprintf("spec.containers{%s}", here.Name), nil | ||
} | ||
} | ||
} | ||
return "", fmt.Errorf("container %#v not found in pod %#v", container, pod) | ||
} |
Oops, something went wrong.