Created
July 24, 2022 01:44
-
-
Save kudoh/c6e015861c1aac9dee46752a1d1c4f6f to your computer and use it in GitHub Desktop.
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
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: server | |
namespace: foo | |
data: | |
server.go: | | |
package main | |
import ( | |
"fmt" | |
"net/http" | |
"os" | |
) | |
func main() { | |
http.HandleFunc("/foo", func(writer http.ResponseWriter, request *http.Request) { | |
fmt.Fprintln(writer, "foo", os.Getenv("POD_NAME")) | |
}) | |
http.ListenAndServe(":8000", nil) | |
} | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: foo | |
namespace: foo | |
spec: | |
selector: | |
matchLabels: | |
app: foo | |
template: | |
metadata: | |
name: foo | |
labels: | |
app: foo | |
spec: | |
volumes: | |
- name: server | |
configMap: | |
name: server | |
containers: | |
- name: foo | |
image: golang | |
ports: | |
- name: http | |
containerPort: 8000 | |
volumeMounts: | |
- name: server | |
mountPath: /app | |
command: [go, run, /app/server.go] | |
env: | |
- name: POD_NAME | |
valueFrom: | |
fieldRef: | |
fieldPath: metadata.name | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: foo | |
namespace: foo | |
spec: | |
selector: | |
app: foo | |
ports: | |
- port: 80 | |
targetPort: http |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment