Skip to content

Instantly share code, notes, and snippets.

View viveksinghggits's full-sized avatar
👋

Vivek Singh viveksinghggits

👋
View GitHub Profile
@viveksinghggits
viveksinghggits / request.js
Created August 13, 2016 06:41
making a cross platform XMLHttpRequest
function createXMLHttpRequestObject(){
if(window.XMLHttpRequest){
xmlHTTPRequest = new XMLHttpRequest();
}
else{
xmlHTTPRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlHTTPRequest;
}
@viveksinghggits
viveksinghggits / main.go
Last active June 15, 2019 23:01
main file to create a simple API
package main
import (
"encoding/json"
"log"
"net/http"
"os"
"github.com/gorilla/mux"
)
@viveksinghggits
viveksinghggits / Dockerfile
Created March 20, 2019 17:46
Dockerfile to containerize the API
FROM golang:1.11
RUN mkdir /go/src/app
ADD . /go/src/app
WORKDIR /go/src/app
#install the external dependecny that we have in the code
RUN go get -u github.com/gorilla/mux
#make the build of the app, output will be an executable file named main
apiVersion: apps/v1
kind: Deployment
metadata:
name: restapi-deployment
labels:
app: restapi
spec:
replicas: 3
selector:
matchLabels:
apiVersion: v1
metadata:
name: restapi-service
spec:
selector:
app: restapi
ports:
- protocol: TCP
port: 8081
targetPort: 8080
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: restapi-ing
spec:
rules:
- http:
paths:
- path: /api/books
backend:
kind: PersistentVolume
apiVersion: v1
metadata:
name: mysql-pv-volume
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 10Gi
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mysql-pv-claim
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
kind: Deployment
apiVersion: apps/v1
metadata:
name: mysql
spec:
replicas: 1
selector:
matchLabels:
app: mysql
strategy:
# Create a pod named nginx-pod with image nginx and 3 replicas
kubectl run nginx-pod --generator=run-pod/v1 --image=nginx --replicas=3
# create a deployment named nginx-deploy with image nginx and 3 replicas, alternative of below command is kubectl create deployment
kubectl run nginx-deploy --image=nginx --replicas=3
# Dont actually create the resources in the cluster, just create the manifest for above commands/resource
# below command will create a file named pod.yaml that will be the manifest to create the pod with require specification.
kubectl run nginx-pod --generator=run-pod/v1 --image=nginx --replicas=3 --dry-run -oyaml > pod.yaml