Package: cdk8s-mongo-sts
cdk8s-mongo-stsCreate a Replicated, Password protected MongoDB Statefulset on Kubernetes, powered by thecdk8s project🚀DisclaimerThis construct is under heavy development, and breaking changes will be introduced very often. Please don't forget to version lock your code if you are using this construct.Overviewcdk8s-mongo-stsis acdk8slibrary, and also usescvallance/mongo-k8s-sidecarto manage the MongoDB replicaset.# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826fromconstructsimportConstructfromcdk8simportApp,Chart,ChartPropsfromcdk8s_mongo_stsimportMyMongoclassMyChart(Chart):def__init__(self,scope,id,*,namespace=None,labels=None):super().__init__(scope,id,namespace=namespace,labels=labels)MyMongo(self,"dev",image="mongo",namespace="databases",default_replicas=3,volume_size="10Gi",create_storage_class=True,volume_provisioner="kubernetes.io/aws-ebs",storage_class_name="io1-slow",storage_class_params={"type":"io1","fs_type":"ext4","iops_per_gB":"10"},node_selector_params={"database":"dev"})app=App()MyChart(app,"asd")app.synth()Create a secret for your DB that starts with the same name as your Statefulset with the following keys :username
passwordSeethisfor documentation on Kubernetes secrets.Then the Kubernetes manifests created bycdk8s synthcommand will have Kubernetes resources such asStatefulset,Service,ClusterRole,ClusterRoleBinding,ServiceAccount, andStorageClassas follows.manifest.k8s.yamlallowVolumeExpansion:trueapiVersion:storage.k8s.io/v1kind:StorageClassmetadata:name:io1-slowparameters:fsType:ext4type:io1iopsPerGB:"10"provisioner:kubernetes.io/aws-ebsreclaimPolicy:Retain---apiVersion:v1kind:Servicemetadata:name:devnamespace:databasesspec:clusterIP:Noneports:-port:27017targetPort:27017selector:db:devtype:ClusterIP---apiVersion:rbac.authorization.k8s.io/v1kind:ClusterRolemetadata:name:get-pods-rolenamespace:databasesrules:-apiGroups:-"*"resources:-podsverbs:-list---apiVersion:v1kind:ServiceAccountmetadata:name:devnamespace:databases---apiVersion:rbac.authorization.k8s.io/v1kind:ClusterRoleBindingmetadata:name:devnamespace:databasesroleRef:apiGroup:""kind:ClusterRolename:get-pods-rolesubjects:-kind:ServiceAccountname:devnamespace:databases---apiVersion:apps/v1kind:StatefulSetmetadata:name:devnamespace:databasesspec:replicas:3selector:matchLabels:db:devserviceName:devtemplate:metadata:labels:db:devspec:containers:-env:-name:MONGO_SIDECAR_POD_LABELSvalue:db=dev-name:KUBE_NAMESPACEvalue:databases-name:MONGODB_DATABASEvalue:admin-name:MONGODB_USERNAMEvalueFrom:secretKeyRef:key:usernamename:dev-name:MONGODB_PASSWORDvalueFrom:secretKeyRef:key:passwordname:devimage:cvallance/mongo-k8s-sidecarname:mongo-sidecar-args:---replSet-rs0---bind_ip-0.0.0.0---dbpath-/data/db---oplogSize-"128"env:-name:MONGO_INITDB_ROOT_USERNAMEvalueFrom:secretKeyRef:key:usernamename:dev-name:MONGO_INITDB_ROOT_PASSWORDvalueFrom:secretKeyRef:key:passwordname:devimage:mongoname:devports:-containerPort:27017resources:limits:cpu:400mmemory:512Mirequests:cpu:200mmemory:256MivolumeMounts:-mountPath:/data/dbname:devnodeSelector:database:devsecurityContext:fsGroup:999runAsGroup:999runAsUser:999serviceAccountName:devterminationGracePeriodSeconds:10volumeClaimTemplates:-metadata:name:devspec:accessModes:-ReadWriteOnceresources:requests:storage:10GistorageClassName:io1-slowInstallationTypeScriptUsenpmoryarnto install.$npminstall-scdk8s-mongo-stsor$yarnaddcdk8s-mongo-stsPython$pipinstallcdk8s-mongo-stsContributionFork (https://github.com/Hunter-Thompson/cdk8s-mongo-sts/fork)Bootstrap the repo:npxprojen# generates package.jsonyarninstall# installs dependenciesDevelopment scripts:CommandDescriptionyarn compileCompiles typescript => javascriptyarn watchWatch & compileyarn testRun unit test & linter through jestyarn test -uUpdate jest snapshotsyarn run packageCreates adistwith packages for all languages.yarn buildCompile + test + packageyarn bumpBump version (with changelog) based on [conventional commits]yarn releaseBump + push tomasterCreate a feature branchCommit your changesRebase your local changes against the master branchCreate a new Pull Request (useconventional commitsfor the title please)LicenceApache License, Version 2.0AuthorHunter-Thompson