Created
February 19, 2019 01:24
-
-
Save philwhln/cabdc868e9b88ae0acb122332a91a79e to your computer and use it in GitHub Desktop.
Test app to understand linkerd routes failure
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
#!/usr/bin/env bash | |
if [ -z "$REMOTE_IMAGE" ]; then | |
echo "Must specify REMOTE_IMAGE" | |
exit 1 | |
fi | |
cat > main.go << GOLANG | |
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
) | |
func handler(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:]) | |
} | |
func main() { | |
http.HandleFunc("/", handler) | |
log.Fatal(http.ListenAndServe(":8080", nil)) | |
} | |
GOLANG | |
cat > manifest.yaml << MANIFEST | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
labels: | |
app: foo | |
name: foo | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: foo | |
template: | |
metadata: | |
labels: | |
app: foo | |
spec: | |
serviceAccountName: service-foo | |
containers: | |
- image: ${REMOTE_IMAGE}:latest | |
name: foo | |
ports: | |
- containerPort: 8080 | |
name: app-port | |
resources: | |
requests: | |
cpu: 100m | |
memory: 256Mi | |
limits: | |
cpu: 100m | |
memory: 256Mi | |
readinessProbe: | |
httpGet: | |
path: / | |
port: app-port | |
livenessProbe: | |
httpGet: | |
path: / | |
port: app-port | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: foo | |
labels: | |
app: foo | |
annotations: | |
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: ${AWS_CERT_ID} | |
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: https | |
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http | |
external-dns.alpha.kubernetes.io/hostname: ${APP_EXTERNAL_HOSTNAME} | |
spec: | |
type: LoadBalancer | |
ports: | |
- port: 443 | |
protocol: TCP | |
name: https | |
targetPort: app-port | |
selector: | |
app: foo | |
--- | |
# ------------------- Vault Auth ------------------- # | |
apiVersion: v1 | |
kind: ServiceAccount | |
metadata: | |
name: service-foo | |
labels: | |
app: foo | |
MANIFEST | |
cat > Dockerfile << DOCKERFILE | |
FROM golang:1.10.4 | |
WORKDIR /go/src/github.com/benchlabs/foo | |
ADD main.go . | |
RUN go build | |
CMD ./foo | |
DOCKERFILE | |
docker build -t "${REMOTE_IMAGE}" . | |
docker push "${REMOTE_IMAGE}" | |
cat manifest.yaml | linkerd inject - | kubectl apply -f - | |
linkerd routes service/foo | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment