Skip to content

Instantly share code, notes, and snippets.

View sarjarapu's full-sized avatar

sarjarapu

  • Amazon Web Services
  • Austin, TX
View GitHub Profile
@sarjarapu
sarjarapu / kubernetes-run.installer.sh
Created July 11, 2018 20:26
Execute install script to install all the required dependencies on a Mac OS
# Install and configure the dependencies for Mac OS
# Dependencies: virtualbox, minikube, kubernetes-helm, bash-completion
sh install.sh
@sarjarapu
sarjarapu / kubernetes-install.helm.chart.sh
Created July 11, 2018 20:27
Install MongoDB Enterprise Operator for Kubernetes using helm
# Download the helm chart from mongodb-enterprise-kubernetes GitHub repo
wget -O master.zip https://github.com/mongodb/mongodb-enterprise-kubernetes/archive/master.zip
unzip master.zip
# Initialize the helm and helm chart
helm init --upgrade
helm install mongodb-enterprise-kubernetes-master/helm_chart/ --name mongodb-enterprise
@sarjarapu
sarjarapu / kubernetes-install.via.kubectl.sh
Created July 11, 2018 20:29
If helm is not available, you may install the operator using kubectl.
# If helm is not available
# Install the enterprise operator via YAML
kubectl apply -f mongodb-enterprise-kubernetes-master/mongodb-enterprise.yaml
@sarjarapu
sarjarapu / kubernetes-environment.sh
Created July 11, 2018 20:31
A script file hold all the environment variables for your MongoDB deployments in Kubernetes
OM_PROJECT_ID="<opsmanager_project_id>"
OM_USER_BASE64=$(echo "<opsmanager_userid>" | base64)
OM_API_KEY_BASE64=$(echo "<opsmanager_public_apikey>" | base64)
OM_URL="<opsmanager_uri>"
K8_NAMESPACE="<kubernetes_namespace>"
MONGODB_VERSION="<mongodb_version>"
@sarjarapu
sarjarapu / kubernetes-environment.example.sh
Created July 11, 2018 20:34
An example script with environment variables set for Ops Manager Url, Kubernetes namespace and MongoDB version
OM_URL="https://cloud.mongodb.com/"
K8_NAMESPACE="mongodb-world"
MONGODB_VERSION="3.6.5"
@sarjarapu
sarjarapu / kubernetes-create.replicaset.sh
Created July 11, 2018 20:37
Shell commands to generate and apply the YAML file to create the MongoDB replica set.
# create the YAML file using the template
sh templates/generate-yaml-simple-replicaset.sh
# create the replica set based on the generated YAML
source templates/environment.sh
kubectl apply -f samples/${K8_NAMESPACE}-replicaset.yaml
@sarjarapu
sarjarapu / kubernetes-display.resources.sh
Created July 11, 2018 20:38
A kubectl command to list all the resources that the helper script has created
# display all the resources in the namespace
kubectl -n $K8_NAMESPACE get all
# NAME READY STATUS RESTARTS AGE
# pod/mongodb-world-replicaset-0 1/1 Running 0 4m
# pod/mongodb-world-replicaset-1 1/1 Running 0 4m
# pod/mongodb-world-replicaset-2 1/1 Running 0 4m
#
# NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) # AGE
# service/mongodb-world-replicaset-svc ClusterIP None <none> 27017/TCP # 4m
# service/mongodb-world-replicaset-svc-external NodePort 10.43.252.153 <none> # 27017:31750/TCP 4m
@sarjarapu
sarjarapu / kubernetes-replicaset.yaml
Last active August 5, 2018 16:16
The auto generated YAML file for creating namespace, configmap, secret and MongoDbReplicaSet
# mongodb-world-replicaset.yaml contents
---
apiVersion: v1
kind: Namespace
metadata:
name: "mongodb-world"
---
apiVersion: v1
kind: ConfigMap
metadata:
@sarjarapu
sarjarapu / kubernetes-connectivity.sh
Created July 11, 2018 20:47
A bash script showing the connectivity to the MongoDB replica set member via mongo shell
kubectl -n ${K8_NAMESPACE} exec -it ${K8_NAMESPACE}-replicaset-0 -- bin/bash
# mongodb@mongodb-world-replicaset-0:/$
/var/lib/mongodb-mms-automation/mongodb-linux-x86_64-3.6.5/bin/mongo
# MongoDB shell version v3.6.5
# connecting to: mongodb://mongodb-world-replicaset-0:27017/
# MongoDB server version: 3.6.5
# mongodb-world-replicaset:PRIMARY>
@sarjarapu
sarjarapu / kubernetes-external.connectivity.sh
Created July 11, 2018 20:48
A bash script showing the connectivity to the MongoDB replica set member using NodePort
kubectl -n ${K8_NAMESPACE} describe pod/mongodb-world-replicaset-0 | grep 'Node:'
# Node: 10.128.0.7
kubectl -n ${K8_NAMESPACE} get services
# NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
# mongodb-world-replicaset-svc ClusterIP None <none> 27017/TCP 41m
# mongodb-world-replicaset-svc-external NodePort 10.43.252.153 <none> 27017:31750/TCP 41m
mongo --host 10.128.0.7 --port 31750
# MongoDB shell version v3.6.5
# connecting to: mongodb://mongodb-world-replicaset-0:27017/
# MongoDB server version: 3.6.5