Skip to content

Instantly share code, notes, and snippets.

@0xAhmed
0xAhmed / k8s-events
Last active October 10, 2017 13:20
Check k8s Events
$ kubectl --namespace=production get events -w
@0xAhmed
0xAhmed / check-deployment-progress
Last active October 10, 2017 13:20
Check k8s Deployment progress
$ kubectl --namespace=production rollout status deployment/kubeapp-production
Waiting for rollout to finish: 1 of 3 updated replicas are available...
Waiting for rollout to finish: 2 of 3 updated replicas are available...
deployment "kubeapp-production" successfully rolled out
@0xAhmed
0xAhmed / apply-deployment
Last active October 10, 2017 13:20
Applying a k8s Deployment
$ kubectl --namespace=production apply -f app-production.yml
@0xAhmed
0xAhmed / create-namespace
Last active October 10, 2017 13:21
Create a Namespace for k8s
$ kubectl create namespace production
@0xAhmed
0xAhmed / parse-project
Last active October 10, 2017 13:21
Sed command to evaluate PROJECT_ID in k8s config
$ sed -i.bak "s#PROJECT_ID#$PROJECT_ID#" app-production.yml
@0xAhmed
0xAhmed / app-stable.yml
Created September 27, 2017 20:05
Example k8s Deployment
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: kubeapp-production
spec:
replicas: 3
template:
metadata:
name: kubeapp
labels:
@0xAhmed
0xAhmed / build-and-push
Last active October 10, 2017 13:28
Build Docker image for 1.0 and push to GCR
$ export app_version=1.0
$ docker build --build-arg version=$app_version -t gcr.io/$PROJECT_ID/app:$app_version .
Sending build context to Docker daemon 16.48MB
Step 1/6 : FROM alpine:latest
---> 7328f6f8b418
Step 2/6 : MAINTAINER The Dockbit Team "[email protected]"
---> Using cache
---> 6abecc069f97
Step 3/6 : ARG version=1.0
@0xAhmed
0xAhmed / Dockerfile
Last active October 3, 2017 12:10
Example Dockerfile for a Go binary
FROM alpine:latest
MAINTAINER The Dockbit Team "[email protected]"
# In case no version is passed
ARG version=1.0
COPY source/$version/app /app
EXPOSE 8080
ENTRYPOINT ["/app"]
@0xAhmed
0xAhmed / build-go
Last active October 10, 2017 13:30
Build a static go binary
$ GOOS=linux GOARCH=amd64 go build -tags netgo -o app
@0xAhmed
0xAhmed / app.go
Created September 25, 2017 14:19
Example Go app for hosting on k8s: Originally hosted at https://github.com/DockbitExamples/kubernetes/blob/master/app/app.go
package main
import (
"fmt"
"net/http"
)
const version string = "1.0"
func getFrontpage(w http.ResponseWriter, r *http.Request) {