├── .dockerignore ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug.yaml │ ├── config.yml │ ├── doc_issue.yaml │ ├── feature.yaml │ └── other.yaml ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── publish-dockerhub.yml │ ├── publish-ghcr.yml │ ├── releases.yml │ ├── vercel-preview.yml │ └── vercel-prod.yml ├── .gitignore ├── .gitpod.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE ├── README.md ├── SECURITY.md ├── babel.config.js ├── compose.yaml ├── docs ├── argocd │ ├── _category_.json │ ├── introduction.md │ ├── learning-resources.md │ ├── manifests │ │ └── declarative.yml │ └── other-resources.md ├── bash-scripting │ ├── _category_.json │ ├── introduction.md │ ├── learning-resources.md │ ├── other-resources.md │ ├── scripts │ │ ├── concepts │ │ │ ├── 1 echo.sh │ │ │ ├── 10 case.sh │ │ │ ├── 11 while.sh │ │ │ ├── 12 until.sh │ │ │ ├── 13 for.sh │ │ │ ├── 14 break-continue.sh │ │ │ ├── 15 function.sh │ │ │ ├── 2 read.sh │ │ │ ├── 3 variables.sh │ │ │ ├── 4 arguments.sh │ │ │ ├── 5 arguments2.sh │ │ │ ├── 6 arithmetic.sh │ │ │ ├── 7 conditionals.sh │ │ │ ├── 8 conditionals1.sh │ │ │ └── 9 conditionals2.sh │ │ ├── crypto-price.sh │ │ ├── ip-alive-check.sh │ │ ├── ping.sh │ │ └── random-quote.sh │ └── tools.md ├── devsecops │ ├── _category_.json │ └── introduction.md ├── docker │ ├── _category_.json │ ├── commands.md │ ├── docker-compose │ │ ├── Dockerfile │ │ ├── compose-template.yml │ │ ├── docker-compose.override.yml │ │ ├── docker-compose.prod.yml │ │ ├── docker-compose.test.yml │ │ ├── docker-compose.yml │ │ ├── drupal-compose.yml │ │ ├── drupal-stack.yaml │ │ ├── psql-fake-password.txt │ │ ├── sample1.yml │ │ ├── sample2.yml │ │ ├── secret-stack-1.yaml │ │ └── secret-stack.yml │ ├── dockerfiles │ │ └── Dockerfile.drupal │ ├── introduction.md │ ├── learning-resources.md │ └── other-resources.md ├── feedback.md ├── git │ ├── _category_.json │ ├── commands.md │ ├── introduction.md │ └── learning-resources.md ├── github-actions │ ├── Workflows │ │ ├── docker-image-dockerhub.yaml │ │ ├── docker-image-ghcr.yaml │ │ └── javascript-linter.yaml │ ├── _category_.json │ ├── introduction.md │ ├── learning-resources.md │ ├── other-resources.md │ └── scenarios.md ├── gitops │ ├── _category_.json │ ├── introduction.md │ └── learning-resources.md ├── golang │ ├── _category_.json │ ├── apps │ │ ├── Discord-bot │ │ │ ├── .env.example │ │ │ ├── bot │ │ │ │ └── bot.go │ │ │ ├── config │ │ │ │ └── config.go │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── main.go │ │ ├── booking-app │ │ │ ├── go.mod │ │ │ ├── main.go │ │ │ └── validator │ │ │ │ └── validator.go │ │ ├── dice-game │ │ │ └── main.go │ │ ├── get-random-quote.go │ │ ├── go-graphql │ │ │ ├── db │ │ │ │ └── mongodb.go │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── gqlgen.yml │ │ │ ├── graph │ │ │ │ ├── generated.go │ │ │ │ ├── model │ │ │ │ │ └── models_gen.go │ │ │ │ ├── resolver.go │ │ │ │ ├── schema.graphqls │ │ │ │ └── schema.resolvers.go │ │ │ ├── handler │ │ │ │ └── handler.go │ │ │ ├── middleware │ │ │ │ └── basicAuth.go │ │ │ └── server.go │ │ ├── http-server │ │ │ ├── api │ │ │ │ └── server.go │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── main.go │ │ ├── jwt-app │ │ │ └── main.go │ │ ├── mongo-api │ │ │ ├── controller │ │ │ │ └── controller.go │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── main.go │ │ │ ├── model │ │ │ │ └── model.go │ │ │ ├── mongo-api │ │ │ └── router │ │ │ │ └── router.go │ │ ├── mux-api │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── main.go │ │ │ └── mux-api │ │ ├── pizza-rating │ │ │ ├── go.mod │ │ │ ├── main.go │ │ │ ├── pizza-rating │ │ │ └── pizza-rating.exe │ │ ├── redis-app │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── main.go │ │ │ └── redis.txt │ │ ├── techcrunch-scrapper │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── main.go │ │ └── viper-app │ │ │ ├── config.json │ │ │ ├── config1.yaml │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── main.go │ ├── concepts │ │ ├── 0) test.go │ │ ├── 1) print.go │ │ ├── 10) array.go │ │ ├── 11) slices.go │ │ ├── 12) slices2.go │ │ ├── 13) map.go │ │ ├── 14) struct.go │ │ ├── 15) if-else.go │ │ ├── 16) loops.go │ │ ├── 17) switch-statements.go │ │ ├── 18) break-continue.go │ │ ├── 19) function.go │ │ ├── 2) Printf.go │ │ ├── 20) methods.go │ │ ├── 21) defer.go │ │ ├── 22) map-ad.go │ │ ├── 23) files.go │ │ ├── 24) handling-web-req.go │ │ ├── 25) handling-url.go │ │ ├── 26) basic-server.go │ │ ├── 26) http-requests.go │ │ ├── 27) json.go │ │ ├── 28) go-routine.go │ │ ├── 29) waitgroup.go │ │ ├── 3) variables.go │ │ ├── 30) waitgroup-api-eg.go │ │ ├── 31) race-condition.go │ │ ├── 32) channels.go │ │ ├── 33) channels-open.go │ │ ├── 34) Interface.go │ │ ├── 35) regex.go │ │ ├── 4) data-types.go │ │ ├── 5) userinput.go │ │ ├── 6) conversions.go │ │ ├── 6) math.go │ │ ├── 6) string-opr.go │ │ ├── 7) time.go │ │ ├── 8) pointers.go │ │ ├── code-org-with-packages │ │ │ ├── go.modddd │ │ │ ├── hello │ │ │ │ └── hello.go │ │ │ ├── main.go │ │ │ ├── name │ │ │ │ └── name.go │ │ │ └── wish.go │ │ ├── files │ │ │ ├── main.go │ │ │ └── test.txt │ │ └── my-modules │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── main.go │ ├── introduction.md │ ├── learning-resources.md │ └── other-resources.md ├── helm │ ├── _category_.json │ ├── charts │ │ └── minimal │ │ │ ├── .helmignore │ │ │ ├── Chart.yaml │ │ │ ├── templates │ │ │ ├── NOTES.txt │ │ │ ├── _helpers.tpl │ │ │ └── configmap.yaml │ │ │ ├── values-alt.yaml │ │ │ └── values.yaml │ ├── introduction.md │ └── learning-resources.md ├── introduction.md ├── jenkins │ ├── _category_.json │ ├── docker-setup │ │ ├── Dockerfile │ │ ├── dind.sh │ │ ├── docker.txt │ │ └── jenkins.sh │ ├── introduction.md │ ├── jenkinsfiles │ │ ├── Jenkinsfile │ │ ├── Jenkinsfile-multistage │ │ ├── Jenkinsfile-para │ │ └── script.groovy │ └── learning-resources.md ├── kubernetes │ ├── _category_.json │ ├── apps │ │ ├── deployment-strategies │ │ │ ├── Namespcae.yaml │ │ │ ├── Recreate.yaml │ │ │ ├── RollingUpdate.yaml │ │ │ ├── blue-green │ │ │ │ ├── Blue.Deployment.yaml │ │ │ │ ├── Green.Deployment.yaml │ │ │ │ └── Service.yaml │ │ │ └── canary │ │ │ │ ├── Canray.Deployment.yaml │ │ │ │ ├── Deployment.yaml │ │ │ │ └── Service.yaml │ │ ├── drupal-postgres │ │ │ ├── Drupal.Deployment.yaml │ │ │ ├── Drupal.Service.yaml │ │ │ ├── Namespace.yaml │ │ │ ├── Postgres.Deployment.yaml │ │ │ ├── Postgres.PV.yaml │ │ │ ├── Postgres.PVC.yaml │ │ │ ├── Postgres.Secrets.yaml │ │ │ └── Postgres.Service.yaml │ │ ├── go-node-react-postgres │ │ │ ├── Namespace.yaml │ │ │ ├── README.txt │ │ │ ├── api-golang │ │ │ │ ├── Deployment.yaml │ │ │ │ ├── IngressRoute.yaml │ │ │ │ ├── Secret.yml │ │ │ │ └── Service.yaml │ │ │ ├── api-node │ │ │ │ ├── Deployment.yaml │ │ │ │ ├── IngressRoute.yaml │ │ │ │ ├── Secret.yaml │ │ │ │ └── Service.yaml │ │ │ ├── client-react │ │ │ │ ├── ConfigMap.yaml │ │ │ │ ├── Deployment.yaml │ │ │ │ ├── IngressRoute.yaml │ │ │ │ └── Service.yaml │ │ │ ├── common │ │ │ │ ├── Middleware.yaml │ │ │ │ └── Namespace.yaml │ │ │ └── postgresql │ │ │ │ ├── Job.db-migrator.yaml │ │ │ │ ├── Secret.db-password.yaml │ │ │ │ └── values.yaml │ │ ├── mongo-express │ │ │ ├── MongoDB.Configmap.yaml │ │ │ ├── MongoDB.Deployment.yaml │ │ │ ├── MongoDB.Secret.yaml │ │ │ ├── MongoDB.Service.yaml │ │ │ ├── MongoExpress.Deployment.yaml │ │ │ ├── MongoExpress.Secret.yaml │ │ │ ├── MongoExpress.Service.yaml │ │ │ └── Namespace.yaml │ │ ├── multi-container │ │ │ ├── alpine.yaml │ │ │ └── curlimage.yaml │ │ ├── nginx-custom │ │ │ ├── ConfigMap.yaml │ │ │ ├── Deployment.yaml │ │ │ ├── Namespace.yaml │ │ │ └── Service.yaml │ │ ├── nginx-simple-app │ │ │ ├── Deployment.yaml │ │ │ ├── Namespace.yaml │ │ │ └── Service.yaml │ │ └── statefulset │ │ │ ├── service-nginx-headless.yaml │ │ │ ├── service-nginx.yaml │ │ │ └── stateful.yml │ ├── commands.md │ ├── introduction.md │ ├── k8s-resources-type │ │ ├── configmap │ │ │ ├── configmap-file.yaml │ │ │ ├── configmap-keys.yaml │ │ │ ├── pod-configmap-file.yaml │ │ │ └── pod-configmap-key.yaml │ │ ├── crds │ │ │ └── trivy.txt │ │ ├── cronjob │ │ │ └── cronjob.yaml │ │ ├── daemonset │ │ │ ├── daemonset-nginx.yml │ │ │ └── daemonset.yml │ │ ├── deployment │ │ │ ├── deployment-best-pratices.yaml │ │ │ └── deployment.yaml │ │ ├── gatewayapi │ │ │ ├── deployment.yaml │ │ │ ├── gateway-httproute.yaml │ │ │ ├── gateway.yaml │ │ │ └── service.yaml │ │ ├── ingress │ │ │ ├── deployment.yaml │ │ │ ├── ingress.yaml │ │ │ └── service.yaml │ │ ├── job │ │ │ ├── job-better.yaml │ │ │ └── job.yaml │ │ ├── namespace │ │ │ └── Namespace.yaml │ │ ├── persistentvolume │ │ │ ├── civo │ │ │ │ ├── satefulset-pvc.yaml │ │ │ │ └── service.yaml │ │ │ └── kind │ │ │ │ ├── deployment.yaml │ │ │ │ ├── dynamic │ │ │ │ └── stateful-pvc.yaml │ │ │ │ └── manual │ │ │ │ ├── persistentvolume.yaml │ │ │ │ ├── persistentvolumeclaim.yaml │ │ │ │ └── pod.yaml │ │ ├── pod │ │ │ ├── pod-best-practices.yaml │ │ │ └── pod.yaml │ │ ├── rbac │ │ │ ├── job-no-perms.yaml │ │ │ └── with-prems │ │ │ │ ├── cluster-role-binding-pod-reader.yaml │ │ │ │ ├── cluster-role-pod-reader.yaml │ │ │ │ ├── job-pod-reader.yaml │ │ │ │ └── service-account-pod-reader.yaml │ │ ├── replicaset │ │ │ └── replicaset.yaml │ │ ├── secret │ │ │ ├── a.deployment.yaml │ │ │ ├── a.secret.yaml │ │ │ ├── secret-data.yaml │ │ │ ├── secret-dockerconfigjson.yaml │ │ │ └── secret-string.yaml │ │ ├── service │ │ │ ├── Service-loadbalancer.yaml │ │ │ ├── Service-nodeport.yaml │ │ │ ├── deployment.yml │ │ │ └── service-clusterip.yaml │ │ └── statefulset │ │ │ ├── service-nginx-headless.yaml │ │ │ ├── service-nginx.yaml │ │ │ └── stateful.yml │ ├── learning-resources.md │ ├── other-resources.md │ ├── playground.md │ └── tools │ │ ├── _category_.json │ │ ├── k9s.md │ │ ├── kubent.md │ │ ├── kubescape.md │ │ ├── kustomize │ │ ├── _category_.json │ │ ├── app │ │ │ ├── base │ │ │ │ ├── ConfigMap.yaml │ │ │ │ ├── Deployment.yaml │ │ │ │ ├── Kustomization.yaml │ │ │ │ └── Service.yaml │ │ │ ├── development │ │ │ │ ├── Kustomization.yaml │ │ │ │ └── patches │ │ │ │ │ ├── ConfigMap.yaml │ │ │ │ │ └── Deployment.yaml │ │ │ └── production │ │ │ │ ├── Kustomization.yaml │ │ │ │ └── patches │ │ │ │ ├── ConfigMap.yaml │ │ │ │ └── Deployment.yaml │ │ └── introduction.md │ │ ├── lens.md │ │ ├── portainer.md │ │ └── validkube.md ├── linux │ ├── _category_.json │ ├── commands.md │ ├── introduction.md │ └── learning-resources.md ├── networking │ ├── _category_.json │ ├── commands.md │ ├── introduction.md │ └── learning-resources.md ├── prometheus │ ├── _category_.json │ ├── introduction.md │ └── learning-resources.md ├── qna.md ├── terraform │ ├── _category_.json │ ├── commands.md │ ├── files │ │ ├── Terraform-KodeKloud.pdf │ │ ├── aws │ │ │ ├── aws-provider.tf │ │ │ ├── backend-s3.tf │ │ │ ├── iam-user-policy.tf │ │ │ ├── multiple-iam-users.tf │ │ │ └── s3-bucket-object-group.tf │ │ ├── count │ │ │ ├── main.tf │ │ │ └── variable.tf │ │ ├── dependencies-type │ │ │ ├── explicit │ │ │ │ └── explicit.tf │ │ │ └── implicit │ │ │ │ └── implicit.tf │ │ ├── interactive-mode │ │ │ ├── hello.tf │ │ │ ├── hello.txt │ │ │ └── variables.tf │ │ ├── local-files │ │ │ └── local.tf │ │ ├── multiple-providers │ │ │ └── my-pets.tf │ │ ├── output-values │ │ │ ├── main.tf │ │ │ └── outputs.tf │ │ ├── test │ │ │ ├── cats.txt │ │ │ ├── dogs.txt │ │ │ ├── main.tf │ │ │ └── pets.txt │ │ └── variable-definition │ │ │ ├── hello.tf │ │ │ ├── hello.txt │ │ │ ├── terraform.tfvars │ │ │ └── variables.tf │ ├── introduction.md │ └── learning-resources.md ├── webassembly │ ├── _category_.json │ ├── files │ │ └── apps │ │ │ ├── hello-wat │ │ │ ├── hello-wasm.html │ │ │ ├── hello-wasm.wasm │ │ │ └── hello-wasm.wat │ │ │ ├── hello-world │ │ │ ├── hello.c │ │ │ ├── hello.html │ │ │ ├── hello.js │ │ │ └── hello.wasm │ │ │ └── kodekloud │ │ │ ├── Section 1.pdf │ │ │ ├── Section 2.pdf │ │ │ ├── Section 3.pdf │ │ │ ├── Section 4.pdf │ │ │ └── Section 6.pdf │ ├── introduction.md │ ├── learning-resources.md │ └── tools.md └── yaml │ ├── _category_.json │ ├── introduction.md │ ├── learning-resources.md │ └── tools.md ├── docusaurus.config.js ├── package-lock.json ├── package.json ├── sidebars.js ├── src ├── components │ └── HomepageFeatures │ │ ├── index.js │ │ └── styles.module.css └── css │ └── custom.css └── static ├── .nojekyll ├── doc └── k8s-troubleshooting.jpg └── img ├── devops-lifecycle.png ├── devops-repo-card.png ├── favicon.ico └── logo.svg /.dockerignore: -------------------------------------------------------------------------------- 1 | **/.classpath 2 | **/.dockerignore 3 | **/.env 4 | **/.git 5 | **/.gitignore 6 | **/.project 7 | **/.settings 8 | **/.toolstarget 9 | **/.vs 10 | **/.vscode 11 | **/.next 12 | **/.cache 13 | **/*.*proj.user 14 | **/*.dbmdl 15 | **/*.jfm 16 | **/charts 17 | **/docker-compose* 18 | **/compose.y*ml 19 | **/Dockerfile* 20 | **/node_modules 21 | **/npm-debug.log 22 | **/obj 23 | **/secrets.dev.yaml 24 | **/values.dev.yaml 25 | **/build 26 | **/dist 27 | LICENSE 28 | README.md 29 | CODE 30 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [Pradumnasaraf] 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug.yaml: -------------------------------------------------------------------------------- 1 | name: 🐛 Bug 2 | description: Report an issue to help improve the project. 3 | title: '[BUG] ' 4 | labels: ['bug'] 5 | body: 6 | - type: textarea 7 | id: description 8 | attributes: 9 | label: Description 10 | description: A brief description of the question or issue, also include what you tried and what didn't work 11 | validations: 12 | required: true 13 | - type: textarea 14 | id: screenshots 15 | attributes: 16 | label: Screenshots 17 | description: Please add screenshots if applicable 18 | validations: 19 | required: false 20 | - type: textarea 21 | id: extra_information 22 | attributes: 23 | label: Additional information 24 | description: Is there anything else we should know about this bug report? 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/doc_issue.yaml: -------------------------------------------------------------------------------- 1 | name: 📄 Documentation 2 | description: Found an issue in the documentation? You can use this one! 3 | title: '[DOCS] ' 4 | labels: ['documentation'] 5 | body: 6 | - type: textarea 7 | id: description 8 | attributes: 9 | label: Description 10 | description: Description of the question or issue, also include what you tried and what didn't work 11 | validations: 12 | required: true 13 | - type: textarea 14 | id: screenshots 15 | attributes: 16 | label: Screenshots 17 | description: Screenshots if applicable 18 | validations: 19 | required: false 20 | - type: textarea 21 | id: extra_information 22 | attributes: 23 | label: Additional information 24 | description: Is there anything else we should know about this report? 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature.yaml: -------------------------------------------------------------------------------- 1 | name: 💡 General Feature Request 2 | description: Have a new idea/feature for my portfolio? Please suggest! 3 | title: '[FEATURE] ' 4 | labels: ['feature'] 5 | body: 6 | - type: textarea 7 | id: description 8 | attributes: 9 | label: Description 10 | description: Description of the enhancement you propose, also include what you tried and what worked. 11 | validations: 12 | required: true 13 | - type: textarea 14 | id: screenshots 15 | attributes: 16 | label: Screenshots 17 | description: Screenshots if applicable 18 | validations: 19 | required: false 20 | - type: textarea 21 | id: extra_information 22 | attributes: 23 | label: Additional information 24 | description: Is there anything else we should know about this feature request? 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/other.yaml: -------------------------------------------------------------------------------- 1 | name: ❗ Other 2 | description: Use this for any other issues. Please do NOT create blank issues 3 | title: '[OTHER] ' 4 | labels: ['other'] 5 | body: 6 | - type: textarea 7 | id: issuedescription 8 | attributes: 9 | label: What would you like to share? 10 | description: Provide a clear and concise explanation of your issue. 11 | validations: 12 | required: true 13 | - type: textarea 14 | id: extra_information 15 | attributes: 16 | label: Additional information 17 | description: Is there anything else we should know about this report? 18 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ### Fixes Issue 4 | 5 | 6 | 7 | 8 | 9 | ### Changes proposed 10 | 11 | 12 | 13 | ### Check List (Check all the applicable boxes) 14 | 15 | 16 | 20 | 21 | - [ ] My code follows the code style of this project. 22 | - [ ] This PR does not contain plagiarized content. 23 | - [ ] The title of my pull request is a short description of the requested changes. 24 | 25 | ### Note to reviewers 26 | 27 | 28 | 29 | ### Screenshots -------------------------------------------------------------------------------- /.github/workflows/publish-dockerhub.yml: -------------------------------------------------------------------------------- 1 | name: Publish Image to DockerHub 2 | 3 | on: 4 | workflow_dispatch: 5 | release: 6 | types: [published] 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v4 14 | 15 | - name: get-npm-version 16 | id: package-version 17 | uses: martinbeentjes/npm-get-version-action@v1.3.1 18 | 19 | - name: DockerHub Login 20 | uses: docker/login-action@v3 21 | with: 22 | username: ${{ secrets.DOCKERHUB_USERNAME }} 23 | password: ${{ secrets.DOCKERHUB_TOKEN }} 24 | 25 | - name: Set up Docker Buildx 26 | uses: docker/setup-buildx-action@v3 27 | 28 | - name: Build and push Docker image 29 | uses: docker/build-push-action@v6 30 | with: 31 | context: . 32 | file: ./Dockerfile 33 | push: true 34 | tags: | 35 | ${{ secrets.DOCKERHUB_USERNAME }}/devops:latest 36 | ${{ secrets.DOCKERHUB_USERNAME }}/devops:${{ steps.package-version.outputs.current-version}} 37 | platforms: linux/amd64,linux/arm64,linux/arm/v7 38 | -------------------------------------------------------------------------------- /.github/workflows/releases.yml: -------------------------------------------------------------------------------- 1 | name: Releases 2 | on: 3 | push: 4 | branches: 5 | - main 6 | 7 | jobs: 8 | changelog: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v4 13 | 14 | - name: conventional Changelog Action 15 | id: changelog 16 | uses: TriPSs/conventional-changelog-action@v5 17 | with: 18 | github-token: ${{ secrets.PA_TOKEN }} 19 | version-file: 'package.json, package-lock.json' 20 | output-file: "false" 21 | create-summary: 'true' 22 | 23 | - name: create release 24 | if: steps.changelog.outputs.skipped == 'false' 25 | uses: ncipollo/release-action@v1 26 | with: 27 | token: ${{ secrets.PA_TOKEN }} 28 | tag : ${{ steps.changelog.outputs.tag }} 29 | name: ${{ steps.changelog.outputs.tag }} 30 | body: ${{ steps.changelog.outputs.clean_changelog }} 31 | -------------------------------------------------------------------------------- /.github/workflows/vercel-preview.yml: -------------------------------------------------------------------------------- 1 | name: Vercel Preview Deployment 2 | env: 3 | VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} 4 | VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} 5 | on: 6 | push: 7 | branches-ignore: 8 | - main 9 | jobs: 10 | Deploy-Preview: 11 | runs-on: ubuntu-latest 12 | environment: 13 | name: preview 14 | steps: 15 | - uses: actions/checkout@v4 16 | - name: Install Vercel CLI 17 | run: npm install --global vercel@latest 18 | - name: Pull Vercel Environment Information 19 | run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} 20 | - name: Build Project Artifacts 21 | run: vercel build --token=${{ secrets.VERCEL_TOKEN }} 22 | - name: Deploy Project Artifacts to Vercel 23 | run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} -------------------------------------------------------------------------------- /.github/workflows/vercel-prod.yml: -------------------------------------------------------------------------------- 1 | name: Vercel Production Deployment 2 | env: 3 | VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} 4 | VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} 5 | on: 6 | push: 7 | branches: 8 | - main 9 | jobs: 10 | Deploy-Production: 11 | runs-on: ubuntu-latest 12 | environment: 13 | name: production 14 | steps: 15 | - uses: actions/checkout@v4 16 | - name: Install Vercel CLI 17 | run: npm install --global vercel@latest 18 | - name: Pull Vercel Environment Information 19 | run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} 20 | - name: Build Project Artifacts 21 | run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} 22 | - name: Deploy Project Artifacts to Vercel 23 | run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | 4 | # Production 5 | /build 6 | 7 | # Generated files 8 | .docusaurus 9 | .cache-loader 10 | 11 | # Misc 12 | .DS_Store 13 | .env.local 14 | .env.development.local 15 | .env.test.local 16 | .env.production.local 17 | 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | 22 | .env 23 | .DS_Store 24 | .vercel 25 | TODO.md 26 | .terraform 27 | .terraform.lock.hcl 28 | terraform.tfstate 29 | terraform.tfstate.backup 30 | terraform.tfvars 31 | .terraform.tfstate.lock.info -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | tasks: 2 | - name: Install dependencies 3 | init: npm install 4 | command: npm start 5 | ports: 6 | - port: 3000 7 | onOpen: open-preview 8 | 9 | github: 10 | prebuilds: 11 | master: true 12 | addBadge: true 13 | addCheck: true 14 | branches: true 15 | addComment: false 16 | pullRequests: true 17 | pullRequestsFromForks: true 18 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | > IMPORTANT **Note** 2 | > 3 | > **Pull Requests having no issue associated with them will not be accepted. Firstly get an issue assigned, whether it's already opened or raised by you, and then create a Pull Request.** 4 | 5 | ## 👨‍💻 Prerequisite 6 | 7 | #### Documention 8 | 9 | - [Git](https://git-scm.com/) 10 | - [Markdown](https://www.markdownguide.org/basic-syntax/) 11 | 12 | #### Code 13 | 14 | - [Node.js](https://nodejs.org/en/) 15 | 16 | ## 💥 How to Contribute 17 | 18 | - Look at the existing [**Issues**](https://github.com/Pradumnasaraf/DevOps/issues) or [**create a new issue**](https://github.com/Pradumnasaraf/DevOps/issues/new/choose)! 19 | - [**Fork the Repo**](https://github.com/Pradumnasaraf/DevOps/fork). Then, create a branch for any issue that you are working on. Finally, commit your work. 20 | - Create a **[Pull Request](https://github.com/Pradumnasaraf/DevOps)** (_PR_), which will be promptly reviewed and given suggestions for improvements by the community. 21 | - Add screenshots or screen captures to your Pull Request to help us understand the effects of the changes proposed in your PR. 22 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ARG NODE_VERSION=20 2 | FROM node:${NODE_VERSION} 3 | 4 | WORKDIR /usr/src/app 5 | 6 | COPY package*.json ./ 7 | RUN npm ci 8 | 9 | COPY . . 10 | 11 | EXPOSE 3000 12 | 13 | CMD ["npm", "start", "--", "--host", "0.0.0.0"] -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | Please don't raise an issue that can be more vulnerable to put out in public. Instead, report via http://pradumnasaraf.dev/contact. 6 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')], 3 | }; 4 | -------------------------------------------------------------------------------- /compose.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | server: 3 | build: 4 | context: . 5 | ports: 6 | - 3000:3000 7 | container_name: server -------------------------------------------------------------------------------- /docs/argocd/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "ArgoCD", 3 | "position": 12 4 | } 5 | -------------------------------------------------------------------------------- /docs/argocd/learning-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | title: Learning Resources 4 | description: A collection of resources to learn more about ArgoCD. 5 | tags: ["ArgoCD", "GitOps", "Kubernetes", "Continuous Delivery"] 6 | keywords: ["ArgoCD", "GitOps", "Kubernetes", "Continuous Delivery"] 7 | slug: "/argocd/resources" 8 | --- 9 | 10 | - [GitOps Tech world with naina (Video)](https://youtu.be/MeU5_k9ssrs) 11 | - [GitOps Fundamentals (Course)](https://learning.codefresh.io/) 12 | -------------------------------------------------------------------------------- /docs/argocd/manifests/declarative.yml: -------------------------------------------------------------------------------- 1 | apiVersion: argoproj.io/v1alpha1 2 | kind: Application 3 | metadata: 4 | name: nginx-app # This is the name of the application 5 | namespace: argocd 6 | spec: 7 | destination: 8 | namespace: argocd # This is the namespace where the application will be deployed 9 | server: https://kubernetes.default.svc # This is the default server 10 | project: default 11 | source: 12 | path: ./manifest # This is the path where the manifest is present 13 | repoURL: https://github.com/sarafpradumna/argo-test # This is the repo where the manifest is present 14 | targetRevision: HEAD 15 | syncPolicy: 16 | automated: 17 | prune: true 18 | selfHeal: true 19 | syncOptions: 20 | - CreateNamespace=true # This will create namespace if not present 21 | 22 | 23 | -------------------------------------------------------------------------------- /docs/argocd/other-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 6 3 | title: Other Resources 4 | description: A collection of resources to learn more about ArgoCD. 5 | tags: ["ArgoCD", "GitOps", "Kubernetes", "Continuous Delivery"] 6 | keywords: ["ArgoCD", "GitOps", "Kubernetes", "Continuous Delivery"] 7 | slug: "/argocd/other-resources" 8 | --- 9 | 10 | Here are list of other resources that you can refer to learn more about ArgoCD: 11 | 12 | - [Sample ArgoCD Manifest files](https://github.com/Pradumnasaraf/DevOps/tree/main/docs/argocd/manifests): A collection of ArgoCD manifest files to help you understand the concepts better. 13 | -------------------------------------------------------------------------------- /docs/bash-scripting/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Bash Scripting", 3 | "position": 16 4 | } 5 | -------------------------------------------------------------------------------- /docs/bash-scripting/learning-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | title: Learning Resources 4 | description: A collection of resources to learn more about Bash Scripting. 5 | tags: ["Bash Scripting", "Linux", "Shell Scripting"] 6 | keywords: ["Bash Scripting", "Linux", "Shell Scripting"] 7 | slug: "/bash/resources" 8 | --- 9 | 10 | - [You need to learn Bash Scripting right now playlist - NetworkChuck (Video)](https://youtube.com/playlist?list=PLIhvC56v63IKioClkSNDjW7iz-6TFvLwS) 11 | - [Devhints Bash Cheat Sheet](https://devhints.io/bash) -------------------------------------------------------------------------------- /docs/bash-scripting/other-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 6 3 | title: Other Resources 4 | description: A collection of resources to learn more about Bash Scripting. 5 | tags: ["Bash Scripting", "Linux", "Shell Scripting"] 6 | keywords: ["Bash Scripting", "Linux", "Shell Scripting"] 7 | slug: "/bash/other-resources" 8 | --- 9 | 10 | Here are list of other resources that you can refer to learn more about Bash Scripting: 11 | 12 | - [Concepts](https://github.com/Pradumnasaraf/DevOps/tree/main/docs/bash-scripting/concepts): Each topic is break into seprate files to help better understand the concepts. 13 | - [Scripts](https://github.com/Pradumnasaraf/DevOps/tree/main/docs/bash-scripting/scripts): A collection of Bash scripts I have created to help you understand the concepts better. 14 | -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/concepts/1 echo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Hi Mom" 4 | 5 | sleep 3 6 | 7 | echo "Hey Rahul" 8 | 9 | sleep 3 10 | 11 | echo "How are you?" 12 | 13 | sleep 3 14 | 15 | echo "I am fine" 16 | 17 | sleep 3 -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/concepts/10 case.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Pick a number from 1 to 3" 4 | read number 5 | 6 | case $number in 7 | 1) 8 | echo "You picked 1" 9 | name="One" 10 | ;; 11 | 2) 12 | echo "You picked 2" 13 | name="Two" 14 | ;; 15 | 3) 16 | echo "You picked 3" 17 | name="Three" 18 | ;; 19 | *) 20 | echo "You did not pick a number from 1 to 3" 21 | ;; 22 | esac 23 | 24 | echo "$name" 25 | 26 | -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/concepts/11 while.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | x=1 4 | 5 | while [[ $x -le 10 ]] 6 | do 7 | echo "The number is $x" 8 | # x=$(( $x + 1 )) 9 | (( x++ )) 10 | done 11 | -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/concepts/12 until.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | until [[ $number -eq 10 ]] 4 | do 5 | echo "The number is $number" 6 | read number 7 | done 8 | echo "You have entered 10" -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/concepts/13 for.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # for cups in 1 2 3 4 5 6 4 | for cups in {1..6} 5 | do 6 | echo "I have $cups cups of coffee" 7 | done -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/concepts/14 break-continue.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | while true 4 | do 5 | read -p "Enter a number: " num 6 | if [[ $num -eq 10 ]]; then 7 | break 8 | elif [[ $num -eq 5 ]]; then 9 | continue 10 | fi 11 | echo "You have entered $num" 12 | done -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/concepts/15 function.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function hello { 4 | echo "Hello World" 5 | } 6 | 7 | hello 8 | -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/concepts/2 read.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Enter your name? " 4 | read name 5 | echo "Hi $name" -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/concepts/3 variables.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | name="Pradumna" 4 | 5 | echo "Hi $name" 6 | echo "You are looking good $name" -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/concepts/4 arguments.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | name=$1 4 | food=$2 5 | 6 | echo "Hi $name" 7 | echo "You like $food" 8 | -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/concepts/5 arguments2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | name=$1 4 | 5 | user=$(whoami) 6 | date=$(date +%F) 7 | whereami=$(pwd) 8 | 9 | echo "Good Morning $name" 10 | 11 | echo "You are curently logged in as $user and you are in the $whereami directory on $date" -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/concepts/6 arithmetic.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "what is your name?" 4 | 5 | read name 6 | 7 | echo "How old are you?" 8 | 9 | read age 10 | 11 | echo "Calculating your future..." 12 | sleep 3 13 | 14 | echo "Hey, $name, you will become millionare in $((($RANDOM % 15)+ $age)) years." -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/concepts/7 conditionals.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Hey, do you like coffee? (y/n)" 4 | 5 | read answer 6 | 7 | if [ $answer == "y" ]; then 8 | echo "Great, I like coffee too!" 9 | else 10 | echo "Oh, I see. I like coffee." 11 | fi -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/concepts/8 conditionals1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | beast=$(( $RANDOM % 2 )) 4 | 5 | echo "Your first besat approcahes. Prepare to fight!. Pick your weapon: (0)Sword (1)Gun" 6 | 7 | read weapon 8 | 9 | if [ $weapon == $beast ]; then 10 | echo "You have slain the beast!" 11 | else 12 | echo "You have been slain by the beast!" 13 | exit 1 14 | fi 15 | 16 | sleep 2 17 | 18 | echo "The fight is not over. You have been transported to a new location. Pick a number between 0 and 1" 19 | 20 | read number 21 | 22 | beast=$(( $RANDOM % 2 )) 23 | 24 | if [ $number == $beast -o $number == "cheat" ]; then 25 | if [ $USER == "pradumnasaraf" ]; then 26 | echo "You have slain the beast!" 27 | else 28 | echo "You have been slain by the beast!" 29 | exit 1 30 | fi 31 | else 32 | echo "You have been slain by the beast!" 33 | exit 1 34 | fi -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/concepts/9 conditionals2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | num=$1 4 | 5 | if [ $num -gt 0 ]; then 6 | echo "The number is positive" 7 | elif [ $num -lt 0 ]; then 8 | echo "The number is negative" 9 | else 10 | echo "The number is zero" 11 | fi -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/crypto-price.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | URL=https://api.coindcx.com/exchange/ticker 4 | 5 | curl -s $URL | jq '.[] | {ticker: .market, price: .last_price}' | jq -r '.ticker + " -> " + .price' -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/ip-alive-check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | read -p "Enter the IP address to ping: " ip 4 | 5 | COUNTER=0 6 | 7 | while true 8 | do 9 | if ping -c 1 $ip > /dev/null; then 10 | echo "Hey, $ip is up!!" 11 | COUNTER=0 12 | break 13 | else 14 | COUNTER=$((COUNTER+1)) 15 | echo "$COUNTER) Hey, $ip is down!!" 16 | fi 17 | sleep 4 18 | done -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/ping.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for x in google.com yahoo.com facebook.com google.coom 4 | do 5 | if ping -c 1 $x > /dev/null 6 | then 7 | echo "$x is up" 8 | else 9 | echo "$x is down" 10 | fi 11 | done 12 | -------------------------------------------------------------------------------- /docs/bash-scripting/scripts/random-quote.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | read -p "How many quotes do you want to see? " NUM 4 | 5 | if [[ -z $NUM ]]; then 6 | echo "Please enter a number" 7 | exit 1 8 | elif [[ $NUM -eq 0 ]]; then 9 | echo "Please enter a number greater than 0" 10 | exit 1 11 | elif [[ $NUM -lt 0 ]]; then 12 | echo "Please enter a positive number" 13 | exit 1 14 | fi 15 | 16 | URL=https://api.quotable.io/random 17 | 18 | for (( i=1; i<=$NUM; i++ )) 19 | do 20 | curl -s $URL | jq -r .content 21 | sleep 1 22 | done 23 | -------------------------------------------------------------------------------- /docs/bash-scripting/tools.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 3 3 | title: Tools 4 | description: A collection of tools that can help you with Bash Scripting. 5 | tags: ["Bash Scripting", "Linux", "Shell Scripting"] 6 | keywords: ["Bash Scripting", "Linux", "Shell Scripting"] 7 | slug: "/bash/tools" 8 | --- 9 | 10 | - [Chmod Calculator](https://chmodcommand.com/) 11 | - [devhints](https://devhints.io/) 12 | - [jq](https://stedolan.github.io/jq/) -------------------------------------------------------------------------------- /docs/devsecops/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "DevSecOps", 3 | "position": 19 4 | } 5 | -------------------------------------------------------------------------------- /docs/devsecops/introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | title: DevSecOps Introduction 4 | description: A collection of resources to learn more about DevSecOps. 5 | tags: ["DevSecOps", "DevOps", "Security"] 6 | keywords: ["DevSecOps", "DevOps", "Security"] 7 | slug: "/devsecops" 8 | --- 9 | 10 | It is a set of practices that combines software development (Dev) and information security (Sec) to shorten the systems development life cycle while providing continuous monitoring to ensure the delivery of secure software. 11 | 12 | - [DevSecOps](https://www.redhat.com/en/topics/devops/what-is-devsecops) 13 | 14 | # MORE INFO COMING SOON -------------------------------------------------------------------------------- /docs/docker/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Docker", 3 | "position": 2 4 | } 5 | -------------------------------------------------------------------------------- /docs/docker/docker-compose/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM drupal:9.3.13 2 | 3 | 4 | RUN apt-get update \ 5 | && apt-get install -y --no-install-recommends \ 6 | git \ 7 | && rm -rf /var/lib/apt/lists/* 8 | 9 | WORKDIR /var/www/html/core 10 | 11 | COPY ./themes ./themes 12 | 13 | WORKDIR /var/www/html 14 | -------------------------------------------------------------------------------- /docs/docker/docker-compose/compose-template.yml: -------------------------------------------------------------------------------- 1 | # version isn't needed as of 2020 for docker compose CLI. 2 | # All 2.x and 3.x features supported 3 | # Docker Swarm still needs a 3.x version 4 | # version: '3.9' 5 | 6 | services: # containers. same as docker run 7 | servicename: # a friendly name. this is also DNS name inside network 8 | image: # Optional if you use build: 9 | command: # Optional, replace the default CMD specified by the image 10 | environment: # Optional, same as -e in docker run 11 | volumes: # Optional, same as -v in docker run 12 | servicename2: 13 | 14 | volumes: # Optional, same as docker volume create 15 | 16 | networks: # Optional, same as docker network create 17 | -------------------------------------------------------------------------------- /docs/docker/docker-compose/docker-compose.override.yml: -------------------------------------------------------------------------------- 1 | version: '3.9' 2 | 3 | services: 4 | 5 | drupal: 6 | build: . 7 | ports: 8 | - "8080:80" 9 | volumes: 10 | - drupal-modules:/var/www/html/modules 11 | - drupal-profiles:/var/www/html/profiles 12 | - drupal-sites:/var/www/html/sites 13 | - ./themes:/var/www/html/themes 14 | 15 | postgres: 16 | environment: 17 | - POSTGRES_PASSWORD_FILE=/run/secrets/psql-pw 18 | secrets: 19 | - psql-pw 20 | volumes: 21 | - drupal-data:/var/lib/postgresql/data 22 | 23 | volumes: 24 | drupal-data: 25 | drupal-modules: 26 | drupal-profiles: 27 | drupal-sites: 28 | drupal-themes: 29 | 30 | secrets: 31 | psql-pw: 32 | file: psql-fake-password.txt 33 | -------------------------------------------------------------------------------- /docs/docker/docker-compose/docker-compose.prod.yml: -------------------------------------------------------------------------------- 1 | version: '3.9' 2 | 3 | services: 4 | 5 | drupal: 6 | ports: 7 | - "80:80" 8 | volumes: 9 | - drupal-modules:/var/www/html/modules 10 | - drupal-profiles:/var/www/html/profiles 11 | - drupal-sites:/var/www/html/sites 12 | - drupal-themes:/var/www/html/themes 13 | 14 | postgres: 15 | environment: 16 | - POSTGRES_PASSWORD_FILE=/run/secrets/psql-pw 17 | secrets: 18 | - psql-pw 19 | volumes: 20 | - drupal-data:/var/lib/postgresql/data 21 | 22 | volumes: 23 | drupal-data: 24 | drupal-modules: 25 | drupal-profiles: 26 | drupal-sites: 27 | drupal-themes: 28 | 29 | secrets: 30 | psql-pw: 31 | external: true 32 | -------------------------------------------------------------------------------- /docs/docker/docker-compose/docker-compose.test.yml: -------------------------------------------------------------------------------- 1 | version: '3.9' 2 | 3 | services: 4 | 5 | drupal: 6 | image: custom-drupal 7 | build: . 8 | ports: 9 | - "80:80" 10 | 11 | postgres: 12 | environment: 13 | - POSTGRES_PASSWORD_FILE=/run/secrets/psql-pw 14 | secrets: 15 | - psql-pw 16 | volumes: 17 | # NOTE: this might be sample data you host in your CI server 18 | # so you can do integration testing with sample data 19 | # this may not work on Docker for Windows/Mac due to bind-mounting 20 | # database data across OSes, which doesn't always work 21 | # in those cases you should use named volumes 22 | - ./sample-data:/var/lib/postgresql/data 23 | secrets: 24 | psql-pw: 25 | file: psql-fake-password.txt 26 | -------------------------------------------------------------------------------- /docs/docker/docker-compose/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.9' 2 | 3 | services: 4 | drupal: 5 | image: custom-drupal:latest 6 | 7 | postgres: 8 | image: postgres:14.3 9 | -------------------------------------------------------------------------------- /docs/docker/docker-compose/drupal-compose.yml: -------------------------------------------------------------------------------- 1 | 2 | version: '3.7' 3 | 4 | services: 5 | drupal: 6 | image: drupal 7 | ports: 8 | - "8080:80" 9 | volumes: 10 | - drupal-modules:/var/www/html/modules 11 | - drupal-profiles:/var/www/html/profiles 12 | - drupal-sites:/var/www/html/sites 13 | - drupal-themes:/var/www/html/themes 14 | postgres: 15 | image: postgres 16 | environment: 17 | - POSTGRES_PASSWORD=postgres 18 | 19 | volumes: 20 | drupal-modules: 21 | drupal-profiles: 22 | drupal-sites: 23 | drupal-themes: 24 | -------------------------------------------------------------------------------- /docs/docker/docker-compose/drupal-stack.yaml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | 3 | services: 4 | drupal: 5 | image: drupal 6 | ports: 7 | - "8080:80" 8 | volumes: 9 | - drupal-modules:/var/www/html/modules 10 | - drupal-profiles:/var/www/html/profiles 11 | - drupal-sites:/var/www/html/sites 12 | - drupal-themes:/var/www/html/themes 13 | deploy: 14 | replicas: 3 15 | 16 | postgres: 17 | image: postgres 18 | environment: 19 | - POSTGRES_PASSWORD=postgres 20 | deploy: 21 | replicas: 2 22 | 23 | 24 | volumes: 25 | drupal-modules: 26 | drupal-profiles: 27 | drupal-sites: 28 | drupal-themes: 29 | -------------------------------------------------------------------------------- /docs/docker/docker-compose/psql-fake-password.txt: -------------------------------------------------------------------------------- 1 | mypasswd 2 | -------------------------------------------------------------------------------- /docs/docker/docker-compose/secret-stack-1.yaml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | 3 | services: 4 | postgres: 5 | image: postgres 6 | secrets: 7 | - post-pass 8 | - post-user 9 | environment: 10 | POSTGRES_PASSWORD_FILE: /run/secrets/post-pass 11 | POSTGRES_USER_FILE: /run/secrets/post-user 12 | 13 | secrets: 14 | post-pass: 15 | external: true 16 | post-user: 17 | file: ./post-user.txt 18 | -------------------------------------------------------------------------------- /docs/docker/docker-compose/secret-stack.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | 3 | services: 4 | psql: 5 | image: postgres 6 | secrets: 7 | - psql_user 8 | - psql_password 9 | environment: 10 | POSTGRES_PASSWORD_FILE: /run/secrets/psql_password 11 | POSTGRES_USER_FILE: /run/secrets/psql_user 12 | 13 | secrets: 14 | psql_user: 15 | file: ./psql_user.txt 16 | psql_password: 17 | file: ./psql_password.txt 18 | -------------------------------------------------------------------------------- /docs/docker/dockerfiles/Dockerfile.drupal: -------------------------------------------------------------------------------- 1 | FROM drupal:9.3.13 2 | 3 | 4 | RUN apt-get update \ 5 | && apt-get install -y --no-install-recommends \ 6 | git \ 7 | && rm -rf /var/lib/apt/lists/* 8 | 9 | # this next part was corrected to be more clear on how you'd typically 10 | # customize your own theme. first you need to clone the theme into this repo 11 | # with something like downloading the lastest theme for bootstrap 12 | # https://www.drupal.org/project/bootstrap and extract into themes dir on host. 13 | # then you'll COPY it into image here: 14 | 15 | WORKDIR /var/www/html/core 16 | 17 | COPY ./themes ./themes 18 | 19 | WORKDIR /var/www/html 20 | -------------------------------------------------------------------------------- /docs/docker/learning-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | title: Learning Resources 4 | description: A collection of resources to learn more about Docker. 5 | tags: ["Docker", "Containerization", "DevOps"] 6 | keywords: ["Docker", "Containerization", "DevOps"] 7 | slug: "/docker/resources" 8 | --- 9 | 10 | - [Docker Mastery (Course)](https://www.udemy.com/course/docker-mastery/) 11 | - [FreeCodeCamp Docker (Video)](https://youtu.be/kTp5xUtcalw) 12 | -------------------------------------------------------------------------------- /docs/docker/other-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 4 3 | title: Other Resources 4 | description: A collection of resources to learn more about Docker. 5 | tags: ["Docker", "Containerization", "DevOps"] 6 | keywords: ["Docker", "Containerization", "DevOps"] 7 | slug: "/docker/other-resources" 8 | --- 9 | 10 | Here are list of other resources that you can refer to learn more about Docker: 11 | 12 | - [Dockerfiles files](https://github.com/Pradumnasaraf/DevOps/tree/main/docs/docker/dockerfiles): A collection of Dockerfiles to help you understand the concepts better. 13 | - [Docker Compose files](https://github.com/Pradumnasaraf/DevOps/tree/main/docs/docker/docker-compose): A collection of Docker Compose files I have created for different applications to help you understand the concepts better. -------------------------------------------------------------------------------- /docs/feedback.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 21 3 | description: Feedback and suggestions 4 | title: Feedback & Suggestions 5 | 6 | --- 7 | 8 | Hey learner, practitioner, or expert in DevOps, 9 | 10 | Thank you so much for checking out this project/website. I ([Pradumna](https://x.com/pradumna_Saraf)) know that this project/website is not perfect and there are many things that can be improved. You might have encountered some errors or outdated information. 11 | 12 | I am always open to feedback and suggestions. If you have any, please feel free to share them. You can raise a [Pull Request](https://github.com/Pradumnasaraf/DevOps) if the changes are minor. If you are unsure about the changes or if it's something major, please first raise an [Issue](https://github.com/Pradumnasaraf/DevOps/issues/new/choose) on the GitHub repo. I will try to incorporate your feedback and suggestions as much as possible. 13 | 14 | Thanks for your time and support. -------------------------------------------------------------------------------- /docs/git/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Git", 3 | "position": 6 4 | } 5 | -------------------------------------------------------------------------------- /docs/git/introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | title: Git Introduction 4 | description: A brief introduction to Git. 5 | tags: ["Git", "Version Control", "Software Development"] 6 | keywords: ["Git", "Version Control", "Software Development"] 7 | slug: "/git" 8 | --- 9 | 10 | Git is a distributed version control system that is used to track changes in source code during software development. It is designed to coordinate work among programmers, but it can be used to track changes in any set of files. Its goals include speed, data integrity, and support for distributed, non-linear workflows. 11 | 12 | ### What's next? 13 | 14 | - [commands](./commands.md) - Learn about the commands that you can use with Git. 15 | - [Learning Resources](./learning-resources.md) - Learn more about Git with these resources. 16 | -------------------------------------------------------------------------------- /docs/git/learning-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | title: Learning Resources 4 | description: A collection of resources to learn more about Git. 5 | tags: ["Git", "Version Control System", "DevOps"] 6 | keywords: ["Git", "Version Control System", "DevOps"] 7 | slug: "/git/resources" 8 | --- 9 | 10 | - [OSWP Resources page](https://github.com/Pradumnasaraf/open-source-with-pradumna/blob/main/pages/Resources.md) 11 | - [learngitbranching.js.org](https://learngitbranching.js.org/) 12 | - [gitexplorer.com](https://gitexplorer.com/) 13 | 14 | ## Local Resources 15 | 16 | - Use `--help` option with any command to get to know how to use the command: 17 | 18 | ```bash 19 | git push --help 20 | ``` 21 | -------------------------------------------------------------------------------- /docs/github-actions/Workflows/docker-image-dockerhub.yaml: -------------------------------------------------------------------------------- 1 | name: Publish Image to DockerHub 2 | 3 | on: 4 | push: 5 | branches: ["main"] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v3 13 | 14 | - name: DockerHub Login 15 | uses: docker/login-action@v2.1.0 16 | with: 17 | username: ${{ secrets.DOCKERHUB_USERNAME }} 18 | password: ${{ secrets.DOCKERHUB_PASSWORD }} 19 | 20 | - name: Build the Docker image 21 | run: docker build . --file Dockerfile --tag ${{ secrets.DOCKERHUB_USERNAME }}/opensource-api 22 | 23 | - name: Docker Push 24 | run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/opensource-api -------------------------------------------------------------------------------- /docs/github-actions/Workflows/docker-image-ghcr.yaml: -------------------------------------------------------------------------------- 1 | name: Publish Package - GHCR 2 | 3 | on: 4 | push: 5 | branches: ['main'] 6 | 7 | env: 8 | REGISTRY: ghcr.io 9 | IMAGE_NAME: ${{ github.repository }} 10 | 11 | jobs: 12 | build-and-push-image: 13 | runs-on: ubuntu-latest 14 | permissions: 15 | contents: read 16 | packages: write 17 | 18 | steps: 19 | - name: Checkout repository 20 | uses: actions/checkout@v3 21 | 22 | - name: Log in to the Container registry 23 | uses: docker/login-action@v2 24 | with: 25 | registry: ${{ env.REGISTRY }} 26 | username: ${{ github.actor }} 27 | password: ${{ secrets.GITHUB_TOKEN }} 28 | 29 | - name: Extract metadata (tags, labels) for Docker 30 | id: meta 31 | uses: docker/metadata-action@v4 32 | with: 33 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 34 | 35 | - name: Build and push Docker image 36 | uses: docker/build-push-action@v4 37 | with: 38 | context: . 39 | push: true 40 | tags: ghcr.io/pradumnasaraf/opensource-api:latest 41 | labels: ${{ steps.meta.outputs.labels }} -------------------------------------------------------------------------------- /docs/github-actions/Workflows/javascript-linter.yaml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | paths: 7 | - "**.js" 8 | pull_request: 9 | paths: 10 | - "**.js" 11 | 12 | jobs: 13 | tests: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - name: Checking and cloning the repo 18 | uses: actions/checkout@v3 19 | 20 | - name: Node Instllation 21 | uses: actions/setup-node@v3 22 | with: 23 | node-version: "18" 24 | 25 | - name: Install dependencies 26 | run: npm ci 27 | 28 | - name: Run lint 29 | run: npm run lint 30 | -------------------------------------------------------------------------------- /docs/github-actions/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "GitHub Actions", 3 | "position": 4 4 | } 5 | -------------------------------------------------------------------------------- /docs/github-actions/learning-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 3 3 | title: Learning Resources 4 | description: A collection of resources to learn more about GitHub Actions. 5 | tags: ["GitHub Actions", "CI/CD", "DevOps"] 6 | keywords: ["GitHub Actions", "CI/CD", "DevOps"] 7 | slug: "/github-actions/resources" 8 | --- 9 | 10 | - [GitHub Actions](https://docs.github.com/en/actions) 11 | - [GitHub Actions: Getting Started](https://docs.github.com/en/actions/learn-github-actions/introduction-to-github-actions) 12 | - [GitHub Action Tutorial - Tech World With Nana](https://youtu.be/R8_veQiYBjI) 13 | - [GitHub Actions Certification - Andrew Brown](https://youtu.be/Tz7FsunBbfQ?si=mq-lzTPSP0wd3Esm). Note, that the video is free on FreeCodeCamp, but certification might be under a paywall. 14 | -------------------------------------------------------------------------------- /docs/github-actions/other-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 4 3 | title: Other Resources 4 | description: A collection of resources to learn more about GitHub Actions. 5 | tags: ["GitHub Actions", "DevOps", "Continuous Integration", "Continuous Deployment"] 6 | keywords: ["GitHub Actions", "DevOps", "Continuous Integration", "Continuous Deployment"] 7 | slug: "/github-actions/other-resources" 8 | --- 9 | 10 | Here are list of other resources that you can refer to learn more about GitHub Actions: 11 | 12 | - [Wokflow files](https://github.com/Pradumnasaraf/DevOps/tree/main/docs/github-actions/Workflows): A collection of GitHub Actions workflow files I use and created to help you understand the concepts better. 13 | -------------------------------------------------------------------------------- /docs/gitops/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "GitOps", 3 | "position": 11 4 | } 5 | -------------------------------------------------------------------------------- /docs/gitops/introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | title: GitOps Introduction 4 | description: Learn about GitOps and its benefits. 5 | tags: ["GitOps", "Kubernetes", "Continuous Delivery"] 6 | keywords: ["GitOps", "Kubernetes", "Continuous Delivery"] 7 | slug: "/gitops" 8 | --- 9 | 10 | GitOps is a way of managing Kubernetes clusters using Git as the source of truth. 11 | 12 | ### Benefits of GitOps 13 | 14 | - History of changes to the cluster is stored in Git 15 | - Rollback to a previous version of the cluster is easy 16 | - Changes to the cluster can be reviewed before they are applied 17 | - Changes to the cluster can be tested before they are applied 18 | - Changes to the cluster can be automated 19 | 20 | ### GitOps Tools 21 | 22 | - [ArgoCD](../argocd/introduction.md) is a git controller that can be used to deploy applications to a Kubernetes cluster. 23 | 24 | ### What's next? 25 | 26 | - [Learning Resources](./learning-resources.md) - Learn more about GitOps with these resources. 27 | - [ArgoCD](../argocd/introduction.md) - Learn more about ArgoCD. -------------------------------------------------------------------------------- /docs/gitops/learning-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | title: Learning Resources 4 | description: A collection of resources to learn more about GitOps. 5 | tags: ["GitOps", "Kubernetes", "Continuous Delivery"] 6 | keywords: ["GitOps", "Kubernetes", "Continuous Delivery"] 7 | slug: "/gitops/resources" 8 | --- 9 | 10 | - [What is GitOps - TechWorld with Nana](https://youtu.be/f5EpcWp0THw) 11 | - [ArgoCD Guide: Full Tutorial for Beginers](https://youtu.be/JLrR9RV9AFA) 12 | -------------------------------------------------------------------------------- /docs/golang/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Golang", 3 | "position": 9 4 | } 5 | -------------------------------------------------------------------------------- /docs/golang/apps/Discord-bot/.env.example: -------------------------------------------------------------------------------- 1 | DISCORD_TOKEN=MTExMzUzNzgxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -------------------------------------------------------------------------------- /docs/golang/apps/Discord-bot/config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "log" 5 | "os" 6 | 7 | "github.com/joho/godotenv" 8 | ) 9 | 10 | var ( 11 | Token string 12 | BotPrefix string 13 | ) 14 | 15 | func LoadConfig() { 16 | err := godotenv.Load() 17 | if err != nil { 18 | log.Fatal("Unable to load .env file") 19 | } 20 | 21 | Token = os.Getenv("DISCORD_BOT_TOKEN") 22 | BotPrefix = os.Getenv("BOT_PREFIX") 23 | } 24 | -------------------------------------------------------------------------------- /docs/golang/apps/Discord-bot/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Pradumnasaraf/discord-bot 2 | 3 | go 1.20 4 | 5 | require ( 6 | github.com/bwmarrin/discordgo v0.27.1 7 | github.com/joho/godotenv v1.5.1 8 | ) 9 | 10 | require ( 11 | github.com/gorilla/websocket v1.4.2 // indirect 12 | golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect 13 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect 14 | ) 15 | -------------------------------------------------------------------------------- /docs/golang/apps/Discord-bot/go.sum: -------------------------------------------------------------------------------- 1 | github.com/bwmarrin/discordgo v0.27.1 h1:ib9AIc/dom1E/fSIulrBwnez0CToJE113ZGt4HoliGY= 2 | github.com/bwmarrin/discordgo v0.27.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY= 3 | github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= 4 | github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= 5 | github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= 6 | github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= 7 | golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b h1:7mWr3k41Qtv8XlltBkDkl8LoP3mpSgBW8BUoxtEdbXg= 8 | golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= 9 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 10 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw= 11 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 12 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 13 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 14 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 15 | -------------------------------------------------------------------------------- /docs/golang/apps/Discord-bot/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | "os/signal" 6 | "syscall" 7 | 8 | "github.com/Pradumnasaraf/discord-bot/bot" 9 | "github.com/Pradumnasaraf/discord-bot/config" 10 | ) 11 | 12 | func main() { 13 | 14 | config.LoadConfig() 15 | 16 | bot.Start() 17 | 18 | sc := make(chan os.Signal, 1) 19 | signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) 20 | <-sc 21 | 22 | } 23 | -------------------------------------------------------------------------------- /docs/golang/apps/booking-app/go.mod: -------------------------------------------------------------------------------- 1 | module booking-app 2 | 3 | go 1.19 4 | -------------------------------------------------------------------------------- /docs/golang/apps/booking-app/validator/validator.go: -------------------------------------------------------------------------------- 1 | package validator 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | func ValidateUserInput(firstName string, lastName string, email string, userTickets uint, remainingTickets uint) (bool, bool, bool) { 8 | isValidName := len(firstName) > 2 && len(lastName) > 3 9 | isValidEmail := strings.Contains(email, "@") && strings.Contains(email, ".") 10 | isVaildTicketNumber := userTickets > 0 && userTickets <= remainingTickets 11 | return isValidName, isValidEmail, isVaildTicketNumber 12 | } 13 | -------------------------------------------------------------------------------- /docs/golang/apps/dice-game/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "math/rand" 6 | ) 7 | 8 | func main() { 9 | 10 | fmt.Println("Welcome to the dice game!") 11 | 12 | diceNumber := rand.Intn(6) + 1 13 | fmt.Println(diceNumber) 14 | 15 | switch diceNumber { 16 | case 1: 17 | fmt.Println("Dice value is 1 and you can open") 18 | case 2: 19 | fmt.Println("Dice value is 2 and you can move 2 steps") 20 | case 3: 21 | fmt.Println("Dice value is 3 and you can move 3 steps") 22 | case 4: 23 | fmt.Println("Dice value is 4 and you can move 4 steps") 24 | case 5: 25 | fmt.Println("Dice value is 5 and you can move 5 steps") 26 | case 6: 27 | fmt.Println("Dice value is 6 and you can move 6 steps and roll the dice again") 28 | default: 29 | fmt.Println("What was that?") 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /docs/golang/apps/get-random-quote.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "io/ioutil" 7 | "net/http" 8 | ) 9 | 10 | type Quote struct { 11 | Id int `json:"_id"` 12 | Content string `json:"content"` 13 | Author string `json:"author"` 14 | Tags []string `json:"tags"` 15 | } 16 | 17 | func main() { 18 | 19 | url := "https://api.quotable.io/random" 20 | 21 | res, err := http.Get(url) 22 | checkNilError(err) 23 | 24 | content, err := ioutil.ReadAll(res.Body) 25 | checkNilError(err) 26 | 27 | defer res.Body.Close() 28 | 29 | quoteData := Quote{} 30 | json.Unmarshal(content, "eData) 31 | 32 | fmt.Println(quoteData.Content) 33 | fmt.Println(quoteData.Author) 34 | 35 | for _, tag := range quoteData.Tags { 36 | fmt.Println(tag) 37 | } 38 | 39 | } 40 | 41 | func checkNilError(err error) { 42 | if err != nil { 43 | panic(err) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /docs/golang/apps/go-graphql/gqlgen.yml: -------------------------------------------------------------------------------- 1 | # Where are all the schema files located? globs are supported eg src/**/*.graphqls 2 | schema: 3 | - graph/*.graphqls 4 | 5 | exec: 6 | filename: graph/generated.go 7 | package: graph 8 | 9 | model: 10 | filename: graph/model/models_gen.go 11 | package: model 12 | 13 | resolver: 14 | layout: follow-schema 15 | dir: graph 16 | package: graph 17 | filename_template: "{name}.resolvers.go" 18 | 19 | autobind: 20 | 21 | models: 22 | ID: 23 | model: 24 | - github.com/99designs/gqlgen/graphql.ID 25 | - github.com/99designs/gqlgen/graphql.Int 26 | - github.com/99designs/gqlgen/graphql.Int64 27 | - github.com/99designs/gqlgen/graphql.Int32 28 | Int: 29 | model: 30 | - github.com/99designs/gqlgen/graphql.Int 31 | - github.com/99designs/gqlgen/graphql.Int64 32 | - github.com/99designs/gqlgen/graphql.Int32 33 | -------------------------------------------------------------------------------- /docs/golang/apps/go-graphql/graph/model/models_gen.go: -------------------------------------------------------------------------------- 1 | // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. 2 | 3 | package model 4 | 5 | type Author struct { 6 | AuthorID string `json:"authorId"` 7 | Name string `json:"name"` 8 | } 9 | 10 | type Video struct { 11 | ID string `json:"id" bson:"_id"` 12 | Title string `json:"title"` 13 | URL string `json:"url"` 14 | Author *Author `json:"author"` 15 | } 16 | 17 | type NewVideo struct { 18 | Title string `json:"title"` 19 | URL string `json:"url"` 20 | AuthorID string `json:"authorId"` 21 | } 22 | -------------------------------------------------------------------------------- /docs/golang/apps/go-graphql/graph/resolver.go: -------------------------------------------------------------------------------- 1 | package graph 2 | 3 | //go:generate go run github.com/99designs/gqlgen 4 | 5 | type Resolver struct { 6 | } 7 | -------------------------------------------------------------------------------- /docs/golang/apps/go-graphql/graph/schema.graphqls: -------------------------------------------------------------------------------- 1 | type Video { 2 | id: ID! 3 | title: String! 4 | url: String! 5 | author: Author! 6 | } 7 | 8 | type Author { 9 | authorId: ID! 10 | name: String! 11 | } 12 | 13 | input newVideo { 14 | title: String! 15 | url: String! 16 | authorId: ID! 17 | } 18 | 19 | type Mutation { 20 | addVideo(input: newVideo!) : Video! 21 | } 22 | 23 | type Query { 24 | videos: [Video!]! 25 | } 26 | -------------------------------------------------------------------------------- /docs/golang/apps/go-graphql/graph/schema.resolvers.go: -------------------------------------------------------------------------------- 1 | package graph 2 | 3 | // This file will be automatically regenerated based on the schema, any resolver implementations 4 | // will be copied through when generating and any unknown code will be moved to the end. 5 | // Code generated by github.com/99designs/gqlgen version v0.17.31 6 | import ( 7 | "context" 8 | "go-grapgql/db" 9 | "go-grapgql/graph/model" 10 | "math/rand" 11 | "strconv" 12 | ) 13 | 14 | var database = db.NewMongoDB() 15 | 16 | // AddVideo is the resolver for the addVideo field. 17 | func (r *mutationResolver) AddVideo(ctx context.Context, input model.NewVideo) (*model.Video, error) { 18 | video := &model.Video{ 19 | ID: strconv.Itoa(rand.Int()), 20 | Title: input.Title, 21 | URL: input.URL, 22 | Author: &model.Author{AuthorID: input.AuthorID, Name: "user" + input.AuthorID}, 23 | } 24 | database.Save(video) 25 | 26 | return video, nil 27 | } 28 | 29 | // Videos is the resolver for the videos field. 30 | func (r *queryResolver) Videos(ctx context.Context) ([]*model.Video, error) { 31 | return database.FindAll(), nil 32 | } 33 | 34 | // Mutation returns MutationResolver implementation. 35 | func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } 36 | 37 | // Query returns QueryResolver implementation. 38 | func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } 39 | 40 | type mutationResolver struct{ *Resolver } 41 | type queryResolver struct{ *Resolver } 42 | -------------------------------------------------------------------------------- /docs/golang/apps/go-graphql/handler/handler.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "go-grapgql/graph" 5 | 6 | "github.com/99designs/gqlgen/graphql/handler" 7 | "github.com/99designs/gqlgen/graphql/playground" 8 | "github.com/gin-gonic/gin" 9 | ) 10 | 11 | // Graphql handler 12 | func GraphqlHandler() gin.HandlerFunc { 13 | h := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}})) 14 | 15 | return func(c *gin.Context) { 16 | h.ServeHTTP(c.Writer, c.Request) 17 | } 18 | } 19 | 20 | // Playground handler 21 | func PlaygroundHandler() gin.HandlerFunc { 22 | h := playground.Handler("GraphQL", "/query") 23 | 24 | return func(c *gin.Context) { 25 | h.ServeHTTP(c.Writer, c.Request) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /docs/golang/apps/go-graphql/middleware/basicAuth.go: -------------------------------------------------------------------------------- 1 | package middleware 2 | 3 | import "github.com/gin-gonic/gin" 4 | 5 | func BasicAuth(username, password string) gin.HandlerFunc { 6 | return gin.BasicAuth(gin.Accounts{ 7 | username: password, 8 | }) 9 | } 10 | -------------------------------------------------------------------------------- /docs/golang/apps/go-graphql/server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "go-grapgql/graph" 5 | "log" 6 | "net/http" 7 | "os" 8 | 9 | "github.com/99designs/gqlgen/graphql/handler" 10 | "github.com/99designs/gqlgen/graphql/playground" 11 | ) 12 | 13 | const defaultPort = "8080" 14 | 15 | func main() { 16 | port := os.Getenv("PORT") 17 | if port == "" { 18 | port = defaultPort 19 | } 20 | 21 | srv := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}})) 22 | 23 | http.Handle("/", playground.Handler("GraphQL playground", "/query")) 24 | http.Handle("/query", srv) 25 | 26 | log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) 27 | log.Fatal(http.ListenAndServe(":"+port, nil)) 28 | } 29 | -------------------------------------------------------------------------------- /docs/golang/apps/http-server/api/server.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | -------------------------------------------------------------------------------- /docs/golang/apps/http-server/go.mod: -------------------------------------------------------------------------------- 1 | module rest-api 2 | 3 | go 1.19 4 | 5 | require ( 6 | github.com/gin-contrib/sse v0.1.0 // indirect 7 | github.com/gin-gonic/gin v1.8.2 // indirect 8 | github.com/go-playground/locales v0.14.0 // indirect 9 | github.com/go-playground/universal-translator v0.18.0 // indirect 10 | github.com/go-playground/validator/v10 v10.11.1 // indirect 11 | github.com/goccy/go-json v0.9.11 // indirect 12 | github.com/json-iterator/go v1.1.12 // indirect 13 | github.com/leodido/go-urn v1.2.1 // indirect 14 | github.com/mattn/go-isatty v0.0.16 // indirect 15 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect 16 | github.com/modern-go/reflect2 v1.0.2 // indirect 17 | github.com/pelletier/go-toml/v2 v2.0.6 // indirect 18 | github.com/ugorji/go/codec v1.2.7 // indirect 19 | golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect 20 | golang.org/x/net v0.4.0 // indirect 21 | golang.org/x/sys v0.3.0 // indirect 22 | golang.org/x/text v0.5.0 // indirect 23 | google.golang.org/protobuf v1.28.1 // indirect 24 | gopkg.in/yaml.v2 v2.4.0 // indirect 25 | ) 26 | -------------------------------------------------------------------------------- /docs/golang/apps/http-server/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | "github.com/gin-gonic/gin" 6 | ) 7 | 8 | type book struct { 9 | ID string `json:"id"` 10 | Title string `json:"title"` 11 | Author string `json:"author"` 12 | Quantity int `json:"quantity"` 13 | } 14 | 15 | var books = []book{ 16 | {ID: "1", Title: "Book 1", Author: "Author 1", Quantity: 10}, 17 | {ID: "2", Title: "Book 2", Author: "Author 2", Quantity: 20}, 18 | {ID: "3", Title: "Book 3", Author: "Author 3", Quantity: 30}, 19 | } 20 | 21 | func getBooks(c *gin.Context){ 22 | c.IndentedJSON(http.StatusOK, books) 23 | } 24 | func createBooks(c *gin.Context){ 25 | var newBook book 26 | if err := c.BindJSON(&newBook); err != nil { 27 | return 28 | } 29 | books = append(books, newBook) 30 | c.IndentedJSON(http.StatusCreated, newBook) 31 | } 32 | 33 | func root (c *gin.Context) { 34 | c.JSON(http.StatusOK, gin.H{ 35 | "message": "API is working fine", 36 | }) 37 | } 38 | 39 | func main(){ 40 | router := gin.Default() 41 | router.GET("/", root) 42 | router.GET("/books", getBooks) 43 | router.POST("/books", createBooks) 44 | router.Run("localhost:8083") 45 | } -------------------------------------------------------------------------------- /docs/golang/apps/jwt-app/main.go: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/golang/apps/mongo-api/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/pradumnasaraf/mongo-api 2 | 3 | go 1.19 4 | 5 | require ( 6 | github.com/golang/snappy v0.0.1 // indirect 7 | github.com/gorilla/mux v1.8.0 // indirect 8 | github.com/klauspost/compress v1.13.6 // indirect 9 | github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect 10 | github.com/pkg/errors v0.9.1 // indirect 11 | github.com/xdg-go/pbkdf2 v1.0.0 // indirect 12 | github.com/xdg-go/scram v1.1.1 // indirect 13 | github.com/xdg-go/stringprep v1.0.3 // indirect 14 | github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect 15 | go.mongodb.org/mongo-driver v1.11.1 // indirect 16 | golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect 17 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect 18 | golang.org/x/text v0.3.7 // indirect 19 | ) 20 | -------------------------------------------------------------------------------- /docs/golang/apps/mongo-api/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net/http" 7 | "github.com/pradumnasaraf/mongo-api/router" 8 | ) 9 | 10 | func main(){ 11 | r := router.Router() 12 | fmt.Println("Server is started...") 13 | log.Fatal(http.ListenAndServe(":4000", r)) 14 | fmt.Print("Listening at port: 4000") 15 | } -------------------------------------------------------------------------------- /docs/golang/apps/mongo-api/model/model.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | import ( 4 | "go.mongodb.org/mongo-driver/bson/primitive" 5 | ) 6 | 7 | type Netflix struct { 8 | ID primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"` 9 | Movie string `json:"movie,omitempty"` 10 | Watched bool `json:"watched,omitempty"` 11 | 12 | } -------------------------------------------------------------------------------- /docs/golang/apps/mongo-api/mongo-api: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pradumnasaraf/DevOps/ca22bd71c59ef36a3732be90e67e4869bd6388de/docs/golang/apps/mongo-api/mongo-api -------------------------------------------------------------------------------- /docs/golang/apps/mongo-api/router/router.go: -------------------------------------------------------------------------------- 1 | package router 2 | 3 | import ( 4 | "github.com/gorilla/mux" 5 | "github.com/pradumnasaraf/mongo-api/controller" 6 | ) 7 | 8 | func Router() *mux.Router { 9 | router := mux.NewRouter() 10 | router.HandleFunc("/", controller.ServeHomepage).Methods("GET") 11 | router.HandleFunc("/api/movie/{id}", controller.GetAMovie).Methods("GET") 12 | router.HandleFunc("/api/movies", controller.GetMyAllMovie).Methods("GET") 13 | router.HandleFunc("/api/movie", controller.CreateMovie).Methods("POST") 14 | router.HandleFunc("/api/movie/{id}", controller.MarkAsWatched).Methods("PUT") 15 | router.HandleFunc("/api/movie/{id}", controller.DeleteAMovie).Methods("DELETE") 16 | router.HandleFunc("/api/movies", controller.DeleteMyAllMovie).Methods("DELETE") 17 | 18 | return router 19 | } 20 | -------------------------------------------------------------------------------- /docs/golang/apps/mux-api/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Pradumnasaraf/mux-api 2 | 3 | go 1.19 4 | 5 | require github.com/gorilla/mux v1.8.0 6 | -------------------------------------------------------------------------------- /docs/golang/apps/mux-api/go.sum: -------------------------------------------------------------------------------- 1 | github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= 2 | github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= 3 | -------------------------------------------------------------------------------- /docs/golang/apps/mux-api/mux-api: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pradumnasaraf/DevOps/ca22bd71c59ef36a3732be90e67e4869bd6388de/docs/golang/apps/mux-api/mux-api -------------------------------------------------------------------------------- /docs/golang/apps/pizza-rating/go.mod: -------------------------------------------------------------------------------- 1 | module pizza-rating 2 | 3 | go 1.19 4 | -------------------------------------------------------------------------------- /docs/golang/apps/pizza-rating/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "os" 7 | "strconv" 8 | "strings" 9 | ) 10 | 11 | func main() { 12 | fmt.Println("Welcome to Pizza app") 13 | fmt.Println("Plesae rate our pizza from 1 to 5") 14 | 15 | reader := bufio.NewReader(os.Stdin) // create a reader object 16 | intput, _ := reader.ReadString('\n') 17 | 18 | fmt.Println("Thanks for rating our pizza", intput) 19 | 20 | numRating, err := strconv.ParseInt(strings.TrimSpace(intput), 10, 64) 21 | 22 | if err != nil { 23 | fmt.Println("Error:", err) 24 | } else { 25 | fmt.Println("Thanks for rating our pizza, add 1 to your ratting", numRating+1) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /docs/golang/apps/pizza-rating/pizza-rating: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pradumnasaraf/DevOps/ca22bd71c59ef36a3732be90e67e4869bd6388de/docs/golang/apps/pizza-rating/pizza-rating -------------------------------------------------------------------------------- /docs/golang/apps/pizza-rating/pizza-rating.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pradumnasaraf/DevOps/ca22bd71c59ef36a3732be90e67e4869bd6388de/docs/golang/apps/pizza-rating/pizza-rating.exe -------------------------------------------------------------------------------- /docs/golang/apps/redis-app/go.mod: -------------------------------------------------------------------------------- 1 | module redis-app 2 | 3 | go 1.20 4 | 5 | require ( 6 | github.com/gofiber/fiber/v2 v2.43.0 7 | github.com/joho/godotenv v1.5.1 8 | github.com/redis/go-redis/v9 v9.0.3 9 | ) 10 | 11 | require ( 12 | github.com/andybalholm/brotli v1.0.5 // indirect 13 | github.com/cespare/xxhash/v2 v2.2.0 // indirect 14 | github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect 15 | github.com/google/uuid v1.3.0 // indirect 16 | github.com/klauspost/compress v1.16.3 // indirect 17 | github.com/mattn/go-colorable v0.1.13 // indirect 18 | github.com/mattn/go-isatty v0.0.17 // indirect 19 | github.com/mattn/go-runewidth v0.0.14 // indirect 20 | github.com/philhofer/fwd v1.1.2 // indirect 21 | github.com/rivo/uniseg v0.2.0 // indirect 22 | github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94 // indirect 23 | github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect 24 | github.com/tinylib/msgp v1.1.8 // indirect 25 | github.com/valyala/bytebufferpool v1.0.0 // indirect 26 | github.com/valyala/fasthttp v1.45.0 // indirect 27 | github.com/valyala/tcplisten v1.0.0 // indirect 28 | golang.org/x/sys v0.6.0 // indirect 29 | ) 30 | -------------------------------------------------------------------------------- /docs/golang/apps/redis-app/redis.txt: -------------------------------------------------------------------------------- 1 | # Redis-App 2 | 3 | ## Tech Stack 4 | 5 | The App is build with Fiber and Redis. I am using Docker to run the Redis Server 6 | 7 | ## App Workflow 8 | 9 | The app contains two endpoints `/post` and `/get`. 10 | 11 | First endpoint is used to create a user in Redis with the key and value both as the `username` which will sent visa POST request to the `/post` endpoint. 12 | 13 | Second endpoint is used to check the user by sending a GET request to the `/get` endpoint with `username` as the parameter. 14 | 15 | Note: The data added by the POST request get expired after 3600 seconds. So, the GET request will return error. If you remove the expiration, head over to `main.go` chnage the `time.Second` to `0` in the following line. 16 | 17 | ```go 18 | err = rdb.Set(ctx, user.UserName, user.UserName, 60*time.Second).Err() 19 | ``` 20 | -------------------------------------------------------------------------------- /docs/golang/apps/techcrunch-scrapper/go.mod: -------------------------------------------------------------------------------- 1 | module Pradumnasaraf/techcrunch-scraper 2 | 3 | go 1.20 4 | 5 | require github.com/PuerkitoBio/goquery v1.8.1 6 | 7 | require ( 8 | github.com/andybalholm/cascadia v1.3.1 // indirect 9 | golang.org/x/net v0.7.0 // indirect 10 | ) 11 | -------------------------------------------------------------------------------- /docs/golang/apps/techcrunch-scrapper/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net/http" 7 | "strings" 8 | 9 | "github.com/PuerkitoBio/goquery" 10 | ) 11 | 12 | func main() { 13 | 14 | blogPosts, err := GetLatestBlogTitles("https://www.techcrunch.com/") 15 | if err != nil { 16 | log.Println(err) 17 | return 18 | } 19 | 20 | if blogPosts == "" { 21 | fmt.Println("No Blog Titles Found") 22 | return 23 | } 24 | 25 | fmt.Println("Blog Post Found: ") 26 | fmt.Println(blogPosts) 27 | } 28 | 29 | func GetLatestBlogTitles(url string) (string, error) { 30 | res, err := http.Get(url) 31 | if err != nil { 32 | return "", err 33 | } 34 | 35 | defer res.Body.Close() 36 | 37 | doc, err := goquery.NewDocumentFromReader(res.Body) 38 | if err != nil { 39 | return "", err 40 | } 41 | 42 | blogPosts := "" 43 | 44 | doc.Find("div.river").Find("div.post-block").Each(func(i int, item *goquery.Selection) { 45 | title := strings.TrimSpace(item.Find("h2.post-block__title").Text()) 46 | urls := strings.TrimSpace(item.Find("h2.post-block__title").Find("a").AttrOr("href", "")) 47 | author := strings.TrimSpace(item.Find("span.river-byline__authors").Find("a").Text()) 48 | time := strings.TrimSpace(item.Find("time.river-byline__time").Text()) 49 | 50 | blogPosts += "- " + title + " (by " + author + " at " + time + ")\n " + urls + "\n\n" 51 | 52 | }) 53 | 54 | return blogPosts, nil 55 | 56 | } 57 | -------------------------------------------------------------------------------- /docs/golang/apps/viper-app/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "user": { 3 | "name": "John Doe", 4 | "age": 42, 5 | "address": { 6 | "home": "123 Main St.", 7 | "work": "456 Work St." 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /docs/golang/apps/viper-app/config1.yaml: -------------------------------------------------------------------------------- 1 | user: 2 | address: 3 | home: 123 Main St. 4 | work: 456 Work St. 5 | age: 42 6 | name: Prad 7 | -------------------------------------------------------------------------------- /docs/golang/apps/viper-app/go.mod: -------------------------------------------------------------------------------- 1 | module viperapp 2 | 3 | go 1.20 4 | 5 | require github.com/spf13/viper v1.15.0 6 | 7 | require ( 8 | github.com/fsnotify/fsnotify v1.6.0 // indirect 9 | github.com/hashicorp/hcl v1.0.0 // indirect 10 | github.com/magiconair/properties v1.8.7 // indirect 11 | github.com/mitchellh/mapstructure v1.5.0 // indirect 12 | github.com/pelletier/go-toml/v2 v2.0.6 // indirect 13 | github.com/spf13/afero v1.9.3 // indirect 14 | github.com/spf13/cast v1.5.0 // indirect 15 | github.com/spf13/jwalterweatherman v1.1.0 // indirect 16 | github.com/spf13/pflag v1.0.5 // indirect 17 | github.com/subosito/gotenv v1.4.2 // indirect 18 | golang.org/x/sys v0.3.0 // indirect 19 | golang.org/x/text v0.5.0 // indirect 20 | gopkg.in/ini.v1 v1.67.0 // indirect 21 | gopkg.in/yaml.v3 v3.0.1 // indirect 22 | ) 23 | -------------------------------------------------------------------------------- /docs/golang/apps/viper-app/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/spf13/viper" 7 | ) 8 | 9 | func main() { 10 | vp := viper.New() 11 | 12 | vp.SetConfigType("json") 13 | vp.SetConfigName("config") 14 | // vp.SetConfigType("yaml") 15 | // vp.SetConfigName("config1") 16 | vp.AddConfigPath(".") 17 | err := vp.ReadInConfig() 18 | if err != nil { 19 | fmt.Println(err) 20 | } 21 | fmt.Println(vp.GetString("user.name")) 22 | fmt.Println(vp.GetString("user.age")) 23 | } 24 | -------------------------------------------------------------------------------- /docs/golang/concepts/0) test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var num int = 42 7 | var numFloat float64 = float64(num) 8 | 9 | var numFloat2 = 3.14 10 | var numInt = int(numFloat2) 11 | 12 | fmt.Println(numFloat) 13 | fmt.Println(numInt) 14 | } 15 | 16 | -------------------------------------------------------------------------------- /docs/golang/concepts/1) print.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main(){ 6 | var name = "Pradumna" 7 | fmt.Print("Hello World") // Print does not add a new line at the end 8 | fmt.Println("Hello World") // Println adds a new line at the end 9 | fmt.Println("Hello World" , name) // , adds a space between the strings 10 | } -------------------------------------------------------------------------------- /docs/golang/concepts/10) array.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | 7 | // Array has fixed size and slice has dynamic size 8 | 9 | var nameArray1 = [5]string{} // Array declaration with size 5 10 | var nameArray [5]string // Array declaration with size 5 11 | 12 | nameArray[0] = "John" 13 | nameArray1[0] = "Doe" 14 | nameArray1[4] = "Doe" 15 | //nameArray1[14] = "Doe" - Not possible as array size is 5 16 | 17 | 18 | fmt.Println(nameArray) 19 | fmt.Println(nameArray1) 20 | fmt.Println(nameArray1[0]) 21 | fmt.Printf("Array type: %T\n" , nameArray1) 22 | fmt.Println(len(nameArray1)) 23 | 24 | } 25 | -------------------------------------------------------------------------------- /docs/golang/concepts/11) slices.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sort" 6 | ) 7 | 8 | func main() { 9 | var fruits []string // We don't need to specify the size of the array 10 | // fruits := []string{} - We can also use this syntax to create a slice 11 | // fruits := make([]string, 2) - We can also use make function to create a slice 12 | fruits = append(fruits, "Apple") 13 | fruits = append(fruits, "Orange") 14 | fruits = append(fruits, "Banana") 15 | fruits = append(fruits, "Grapes") 16 | 17 | fmt.Println(fruits) 18 | fmt.Println(len(fruits)) // length of the array 19 | fmt.Println(fruits[1:]) // from index 1 to end 20 | fmt.Println(fruits[:3]) // from index 0 to 3 , 3 is not included. 21 | fmt.Println(fruits[1:3]) // from index 1 to 3 , 3 is not included. 22 | 23 | fmt.Println(sort.StringsAreSorted(fruits)) // check if the array is sorted 24 | 25 | sort.Strings(fruits) // sort the array 26 | fmt.Println(fruits) 27 | 28 | fmt.Println(sort.StringsAreSorted(fruits)) 29 | } 30 | -------------------------------------------------------------------------------- /docs/golang/concepts/12) slices2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | // remove an element from a slice 7 | var cars = []string{"BMW", "Audi", "Mercedes", "Ford", "Fiat"} 8 | 9 | fmt.Println(cars) 10 | var index int = 2 11 | // We are concatenating two slice and rewriting the 1st Slice. 12 | cars = append(cars[:index], cars[index+1:]...) // remove the element at index 2. :index is from 0 to index-1, [index+1:] is from index+1 to end. We can append both elements as well as a slice. ... is to denote a slice 13 | fmt.Println(cars) 14 | 15 | } 16 | -------------------------------------------------------------------------------- /docs/golang/concepts/13) map.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func main() { 8 | var languages = map[string]string{} 9 | // var languages = make(map[string]string, 0) // create a slice of maps with a length of 0. // map[keyType]valueType 10 | 11 | //laguages[key] = value 12 | languages["JS"] = "JavaScript" 13 | languages["PY"] = "Python" 14 | languages["GO"] = "Go" 15 | languages["RB"] = "Ruby" 16 | 17 | fmt.Println(languages) 18 | fmt.Println(languages["JS"]) // access the value of a key 19 | 20 | delete(languages, "RB") // Deleting a Key (No key means no Value as well) 21 | fmt.Println(languages) 22 | 23 | for key, value := range languages { 24 | fmt.Println(key, value) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /docs/golang/concepts/14) struct.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | 6 | type UserData struct { // struct is a collection of fields. 7 | fistName string 8 | lastName string 9 | email string 10 | numberOfTickets int 11 | } 12 | 13 | func main() { 14 | user := UserData{ // struct initialization 15 | fistName: "John", 16 | lastName: "Doe", 17 | email: "pradumnasaraf@gmail.com", 18 | numberOfTickets: 2, 19 | } 20 | fmt.Println(user.fistName) 21 | fmt.Println(user) 22 | 23 | user2 := UserData{ "Jon", "Doe", "jpo@mail.com", 2 } // struct initialization 24 | fmt.Println(user2.fistName) 25 | fmt.Println(user2) // prints the struct 26 | fmt.Printf("Details are %+v", user2) // %+v prints the struct with field names 27 | } -------------------------------------------------------------------------------- /docs/golang/concepts/15) if-else.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func main() { 8 | var name int = 9 9 | 10 | // The pro 11 | 12 | if name > 10 { 13 | fmt.Println("Your number is greater than 10") 14 | } else if name == 10 { 15 | fmt.Println("Your number is equal to 10") 16 | } else { 17 | fmt.Println("Your number is less than 10") 18 | } 19 | 20 | if 9%2 == 0 { 21 | fmt.Println("9 is even") 22 | } else { 23 | fmt.Println("9 is odd") 24 | } 25 | 26 | // The if statement can start with a short statement to execute before the condition 27 | 28 | if num := 9; num < 0 { // ; is used to separate the short statement from the condition 29 | fmt.Println(num, "is negative") 30 | } else { 31 | fmt.Println(num, "is positive") 32 | } 33 | 34 | // if err != nil { // comma ok syntax 35 | // return err 36 | // } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /docs/golang/concepts/16) loops.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func main() { 8 | 9 | // for { 10 | // fmt.Println("This is an infinite loop") 11 | // } 12 | 13 | sum := 0 14 | for i := 0; i < 10; i++ { //for [initialization]; [condition]; [post] { } 15 | sum += i 16 | } 17 | fmt.Println(sum) 18 | 19 | days := []string{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"} 20 | 21 | for i := 0; i < len(days); i++ { // Simple wy to iterate over an array 22 | fmt.Println(days[i]) 23 | } 24 | 25 | // for [index] := range [array] { } 26 | for i := range days { // Better way to iterate over an array 27 | fmt.Println(days[i]) 28 | } 29 | 30 | // for [index], [value] := range [array] { } 31 | for i, day := range days { // This is the preferred way to iterate over an array 32 | fmt.Println(i, day) // i is the index and day is the value 33 | } 34 | 35 | // for _, [value] := range [array] { } 36 | for _, day := range days { // we can ignore the index by using _ 37 | fmt.Println(day) 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /docs/golang/concepts/17) switch-statements.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | 5 | city := "paris" 6 | 7 | switch city { 8 | case "london", "manchester": // Here we are checking for multiple values with the same output 9 | println("London or Manchester") 10 | case "paris": 11 | println("Paris ") 12 | fallthrough 13 | case "rome": 14 | println("Rome ") 15 | default: // This is the default case 16 | println("I don't know where that is") 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /docs/golang/concepts/18) break-continue.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | // continue: Will skip that ireration, but will not break the look unlike "break" 8 | 9 | func main() { 10 | for i := 0; i < 5; i++ { 11 | if i == 3 { // Here 3 will not be printed 12 | continue 13 | } 14 | if i == 4 { // From here the loop will get exited without printing 4 15 | break 16 | } 17 | fmt.Println(i) // only 0, 1, 2 will be printed 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /docs/golang/concepts/19) function.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | greetUser() // Function call 7 | fmt.Println(addTwoNumbers(2, 3)) 8 | 9 | a, b := returnTwoValues() // Multiple return valeus. 10 | fmt.Println(a, b) 11 | 12 | c, d := addAndSubtract(10, 5) 13 | fmt.Println(c, d) 14 | 15 | fmt.Println(proAdder(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) 16 | } 17 | 18 | func greetUser() { 19 | fmt.Println("Hello, welcome to the app") 20 | } 21 | 22 | func addTwoNumbers(a int, b int) int { // Function with Para and retun value 23 | return a + b 24 | } 25 | 26 | func returnTwoValues() (int, string){ // Function with multiple return values. 27 | return 12, "Hello" 28 | } 29 | 30 | func addAndSubtract(a int, b int) (int, int) { // When we have mmultiple return values, we wrap them in () parenthesis. 31 | return a + b, a - b 32 | } 33 | 34 | func proAdder(value ...int) int { // Function with variable number of parameters. value is a slice of int 35 | sum := 0 36 | for _, v := range value { // value is a slice of int 37 | sum += v 38 | } 39 | return sum 40 | } -------------------------------------------------------------------------------- /docs/golang/concepts/2) Printf.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main(){ 6 | var name = "Pradumna" 7 | 8 | fmt.Printf("Hello World %v\n", name ) // %v is a placeholder for a variable 9 | fmt.Printf("Type: %T", name) // %T is a placeholder for the type of the variable 10 | } 11 | 12 | -------------------------------------------------------------------------------- /docs/golang/concepts/20) methods.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type UserData struct { 6 | fistName string 7 | lastName string 8 | email string 9 | numberOfTickets int 10 | } 11 | 12 | /* 13 | func (receiver Type) MethodName(parameters) returnType { 14 | // method body 15 | } 16 | */ 17 | 18 | func (u UserData) greetUser() { 19 | fmt.Println("Hello", u.fistName, u.lastName) 20 | } 21 | 22 | func main() { 23 | user := UserData{ 24 | fistName: "John", 25 | lastName: "Doe", 26 | email: "pradumnasaraf@gmail.com", 27 | numberOfTickets: 2, 28 | } 29 | 30 | user.greetUser() // Call the method 31 | } 32 | -------------------------------------------------------------------------------- /docs/golang/concepts/21) defer.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | 6 | // Defer statements are run at the end 7 | func main() { 8 | defer fmt.Println("This is the first defer statement") 9 | defer fmt.Println("This is the second defer statement") 10 | defer fmt.Println("This is the third defer statement") 11 | fmt.Println("Hello, playground") 12 | 13 | myDefer( ) 14 | 15 | } 16 | 17 | func myDefer(){ 18 | for i := 0; i < 4; i++ { 19 | defer fmt.Println(i) 20 | } 21 | } -------------------------------------------------------------------------------- /docs/golang/concepts/22) map-ad.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | func main() { 9 | 10 | bookings :=[]map[string]string{} // This is a slice of map. 11 | 12 | for i := 0; i < 1; i++ { 13 | 14 | name := "John" 15 | age := 32 16 | city := "New York" 17 | 18 | myMap := map[string]string{} 19 | 20 | myMap["name"] = name 21 | myMap["age"] = strconv.FormatInt(int64(age), 10) 22 | myMap["city"] = city 23 | 24 | bookings = append(bookings, myMap) 25 | bookings = append(bookings, myMap) 26 | bookings = append(bookings, myMap) 27 | 28 | fmt.Println(bookings) 29 | for _ , booking := range bookings { 30 | fmt.Println(booking["name"]) // access the value of a key 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /docs/golang/concepts/23) files.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | ) 8 | 9 | func main() { 10 | 11 | content := "Hey I am Pradumna" 12 | 13 | // Create a file 14 | file, err := os.Create("./hello.txt") 15 | 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | // Writing content in a file 21 | length, err := io.WriteString(file, content) 22 | 23 | if err != nil { 24 | panic(err) 25 | } 26 | 27 | fmt.Println("Length:", length) 28 | 29 | // Reading a file 30 | data, err := os.ReadFile("./hello.txt") 31 | 32 | if err != nil { 33 | panic(err) 34 | 35 | } 36 | 37 | // Print the read data 38 | fmt.Println(string(data)) 39 | 40 | //Removing a file 41 | err = os.Remove("./hello.txt") 42 | 43 | if err != nil { 44 | panic(err) 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /docs/golang/concepts/24) handling-web-req.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "net/http" 7 | ) 8 | 9 | const url = "https://pradumnasaraf.dev" 10 | 11 | func main() { 12 | 13 | res, err := http.Get(url) 14 | checkNilError(err) 15 | 16 | fmt.Printf("Response is of type: %T\n", res) 17 | fmt.Println(res.Status) 18 | fmt.Println(res.Proto) 19 | 20 | dataBytes, err := io.ReadAll(res.Body) //We can't read the response directly. So we use ioutil.ReadAll() 21 | checkNilError(err) 22 | 23 | content := string(dataBytes) // convert the byte array to string 24 | fmt.Println(content) 25 | } 26 | 27 | func checkNilError(err error) { 28 | if err != nil { 29 | panic(err) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /docs/golang/concepts/25) handling-url.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/url" 6 | ) 7 | 8 | const myURL = "https://pradumnasaraf.dev:3000/services?service=twitter" 9 | 10 | func main() { 11 | 12 | // Parsing the URL 13 | results, _ := url.Parse(myURL) 14 | fmt.Println(results.Scheme) // Scheme is the protocol used. Eg: http, https, ftp, etc 15 | fmt.Println(results.Host) // Host is the domain name 16 | fmt.Println(results.Port()) // Port is the port number 17 | fmt.Println(results.RawQuery) // RawQuery is the query string 18 | fmt.Println(results.Query()) // Query is the query string in map form 19 | 20 | data := results.Query() 21 | fmt.Println(data["service"]) 22 | 23 | // &url.URL{} is a pointer to a url.URL type 24 | partsOfUrl := &url.URL{ 25 | Scheme: "https", 26 | Host: "pradumnasaraf.dev", 27 | Path: "/services", 28 | RawQuery: "user=pradumna", 29 | } 30 | 31 | // String() method is used to convert the url.URL type to string 32 | anotherUrl := partsOfUrl.String() 33 | fmt.Println(anotherUrl) 34 | } 35 | -------------------------------------------------------------------------------- /docs/golang/concepts/26) basic-server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | ) 7 | 8 | func main() { 9 | http.HandleFunc("/", hello) 10 | fmt.Print("Server is running on port 8080 \n") 11 | http.ListenAndServe(":8080", nil) 12 | } 13 | 14 | func hello(w http.ResponseWriter, r *http.Request) { // w is used to write the response and r is used to read the request 15 | w.Write([]byte("Hello World")) 16 | } -------------------------------------------------------------------------------- /docs/golang/concepts/26) http-requests.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "log" 7 | "net/http" 8 | "net/url" 9 | "strings" 10 | ) 11 | 12 | const URL = "https://osapi.vercel.app/api/devtip" 13 | 14 | func main() { 15 | 16 | // getReq() 17 | postReq() 18 | 19 | } 20 | 21 | func getReq() { 22 | res, err := http.Get(URL) 23 | checkNilErr(err) 24 | 25 | byteData, err := io.ReadAll(res.Body) 26 | fmt.Println(string(byteData)) 27 | } 28 | 29 | func postReq() { 30 | resBody := strings.NewReader( 31 | `{ 32 | "message": "Eat good food" 33 | }`) 34 | 35 | req, err := http.Post(URL, "application/json", resBody) 36 | 37 | checkNilErr(err) 38 | defer req.Body.Close() 39 | 40 | dataBytes, err := io.ReadAll(req.Body) 41 | fmt.Println("Status Code", req.StatusCode) 42 | fmt.Println("Response Body", string(dataBytes)) 43 | 44 | } 45 | 46 | func checkNilErr(err error) { 47 | if err != nil { 48 | log.Fatal(err) 49 | } 50 | } 51 | 52 | func postFormRequest() { 53 | 54 | const apiUrl = "https://ossapi.vercel.app/api/devtip" 55 | 56 | data := url.Values{} 57 | data.Add("message", "Hey, drink water daily") 58 | 59 | res, err := http.PostForm(apiUrl, data) 60 | 61 | if err != nil { 62 | panic(err) 63 | } 64 | 65 | defer res.Body.Close() 66 | 67 | content, _ := io.ReadAll(res.Body) 68 | fmt.Println(string(content)) 69 | 70 | } 71 | -------------------------------------------------------------------------------- /docs/golang/concepts/28) go-routine.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | go greeter("First Statement") 10 | go greeter("Second Statement") 11 | greeter("Third Statement") 12 | 13 | } 14 | 15 | func greeter(s string) { 16 | 17 | for i := 0; i < 5; i++ { 18 | time.Sleep(1 * time.Second) 19 | fmt.Println(s) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /docs/golang/concepts/29) waitgroup.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | "time" 7 | ) 8 | 9 | var wg sync.WaitGroup // wait group is used to wait for all go routines to finish 10 | 11 | func main() { 12 | wg.Add(1) // add one to the wait group 13 | 14 | go waitFiveSeconds() 15 | fmt.Println("Hello from main") 16 | 17 | wg.Wait() // wait for all go routines to finish 18 | } 19 | 20 | func waitFiveSeconds() { 21 | time.Sleep(5 * time.Second) 22 | fmt.Println("Hello from sayHello") 23 | wg.Done() // subtract one from the wait group 24 | } 25 | -------------------------------------------------------------------------------- /docs/golang/concepts/3) variables.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main(){ 6 | var temp = 20 // temperature can change 7 | const myCity = "Mumbai" // name of the city is constant 8 | name := "Pradumna" // := is a shortcut for declaring and initializing a variable 9 | 10 | fmt.Println("The temperature in", myCity, "is", temp, "degrees") 11 | fmt.Println("My name is", name) 12 | 13 | var name2 string 14 | fmt.Println(name2) 15 | } -------------------------------------------------------------------------------- /docs/golang/concepts/30) waitgroup-api-eg.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "sync" 7 | ) 8 | 9 | var wg sync.WaitGroup 10 | var mut sync.Mutex 11 | var statusCodes = []int{} 12 | 13 | func main() { 14 | 15 | endpoints := []string{ 16 | "https://www.google.com", 17 | "https://www.pradumnasaraf.dev", 18 | "https://www.go.dev", 19 | "https://www.golang.org", 20 | "https://www.github.com", 21 | "https://www.stackoverflow.com", 22 | "https://www.medium.com", 23 | } 24 | 25 | for _, endpoint := range endpoints { 26 | go checkStausCode(endpoint) 27 | wg.Add(1) 28 | } 29 | 30 | wg.Wait() 31 | fmt.Print(statusCodes) 32 | } 33 | 34 | func checkStausCode(endpoint string) { 35 | defer wg.Done() 36 | 37 | res, err := http.Get(endpoint) 38 | if err != nil { 39 | fmt.Println("Problem in the endpoint", endpoint) 40 | } else { 41 | mut.Lock() 42 | statusCodes = append(statusCodes, res.StatusCode) 43 | mut.Unlock() 44 | fmt.Printf("Status code for %s is %d\n", endpoint, res.StatusCode) 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /docs/golang/concepts/31) race-condition.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | ) 7 | 8 | func main() { 9 | wg := &sync.WaitGroup{} 10 | mut := &sync.RWMutex{} 11 | 12 | var score = []int{0} 13 | 14 | wg.Add(3) 15 | 16 | go func(wg *sync.WaitGroup, mut *sync.RWMutex) { 17 | fmt.Println("One Routine") 18 | mut.Lock() // Lock the memory location of score 19 | score = append(score, 1) 20 | mut.Unlock() // Unlock the memory location of score 21 | wg.Done() 22 | }(wg, mut) // Pass the pointer of WaitGroup and Mutex 23 | go func(wg *sync.WaitGroup, mut *sync.RWMutex) { 24 | fmt.Println("Two Routine") 25 | mut.Lock() 26 | score = append(score, 2) 27 | mut.Unlock() 28 | wg.Done() 29 | }(wg, mut) 30 | go func(wg *sync.WaitGroup, mut *sync.RWMutex) { 31 | fmt.Println("Three Routine") 32 | mut.Lock() 33 | score = append(score, 3) 34 | mut.Unlock() 35 | wg.Done() 36 | }(wg, mut) 37 | 38 | wg.Wait() 39 | fmt.Println(score) 40 | 41 | } 42 | -------------------------------------------------------------------------------- /docs/golang/concepts/32) channels.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | ) 7 | 8 | func main() { 9 | 10 | myChannel := make(chan int, 2) // buffered channel 11 | // var myChannel chan int // unbuffered channel 12 | wg := &sync.WaitGroup{} 13 | 14 | 15 | wg.Add(2) 16 | go func(ch chan int, wg *sync.WaitGroup) { 17 | fmt.Println(<-ch) // read from channel 18 | wg.Done() 19 | }(myChannel, wg) 20 | 21 | go func(ch chan int, wg *sync.WaitGroup) { 22 | // close(myChannel) 23 | ch <- 5 // write to channel 24 | ch <- 6 // write to channel 25 | close(myChannel) 26 | wg.Done() 27 | }(myChannel, wg) 28 | 29 | wg.Wait() 30 | } 31 | -------------------------------------------------------------------------------- /docs/golang/concepts/33) channels-open.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | ) 7 | 8 | func main() { 9 | 10 | wg := &sync.WaitGroup{} 11 | myCh := make(chan int, 1) 12 | 13 | wg.Add(2) 14 | go func(channel chan int, wait *sync.WaitGroup) { 15 | fmt.Println("First Go Routine") 16 | wait.Done() 17 | 18 | value, isChannelOpen := <-myCh 19 | 20 | if !isChannelOpen { 21 | fmt.Println("Channel Closed") 22 | } 23 | fmt.Println(value) 24 | }(myCh, wg) 25 | 26 | go func(channel chan int, wait *sync.WaitGroup) { 27 | fmt.Println("Second Go Routine") 28 | // myCh <- 3 29 | close(myCh) 30 | wait.Done() 31 | // myCh <- 5 32 | }(myCh, wg) 33 | 34 | wg.Wait() 35 | } 36 | -------------------------------------------------------------------------------- /docs/golang/concepts/34) Interface.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "math" 6 | ) 7 | 8 | type shape interface { 9 | area() float64 10 | } 11 | type circle struct { 12 | radius float64 13 | } 14 | 15 | type rectangle struct { 16 | width float64 17 | length float64 18 | } 19 | 20 | func (r rectangle) area() float64 { 21 | return r.length * r.width 22 | } 23 | 24 | func (c circle) area() float64 { 25 | return 2 * math.Pi * c.radius 26 | } 27 | 28 | func main() { 29 | myRectangle := rectangle{width: 8, length: 10} 30 | fmt.Println(myRectangle.area()) 31 | 32 | myCircle := circle{radius: 10} 33 | fmt.Println(myCircle.area()) 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /docs/golang/concepts/35) regex.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "regexp" 5 | ) 6 | 7 | func main() { 8 | 9 | // Test the formatAsPlainText function 10 | input := `# Heading 1 11 | 12 | ## Heading 2 13 | 14 | ### Heading 3 15 | 16 | #### Heading 4 17 | 18 | ##### Heading 5 19 | 20 | ###### Heading 6 21 | 22 | --- 23 | 24 | _Italic text_ *Italic text* 25 | 26 | 27 | **Bold text** __Bold text__ 28 | 29 | 30 | _Italic text_ *Italic text* 31 | 32 | ` 33 | 34 | output := formatAsPlainText(input) 35 | println(output) 36 | 37 | } 38 | 39 | func formatAsPlainText(input string) string { 40 | // Remove Markdown headings 41 | re := regexp.MustCompile(`(?m)^#{1,6}\s+(.*)`) 42 | input = re.ReplaceAllString(input, "$1") 43 | 44 | // Remove horizontal rules 45 | re = regexp.MustCompile(`(?m)^\n?-{3,}\n?`) 46 | input = re.ReplaceAllString(input, "\n") 47 | 48 | // Remove bold formatting 49 | re = regexp.MustCompile(`\*\*([^*]+)\*\*|__([^_]+)__`) 50 | input = re.ReplaceAllString(input, "$1$2") 51 | 52 | // Remove italic formatting 53 | re = regexp.MustCompile(`_([^_]+)_|\*([^*]+)\*`) 54 | input = re.ReplaceAllString(input, "$1$2") 55 | 56 | // Replace bullet points with a hyphen 57 | re = regexp.MustCompile(`(?m)^\* (.*)`) 58 | input = re.ReplaceAllString(input, "- $1") 59 | 60 | return input 61 | } 62 | -------------------------------------------------------------------------------- /docs/golang/concepts/4) data-types.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main(){ 6 | var userName string // Declaring a variable 7 | var age int 8 | 9 | userName = "Pradumna" // The go compiler will infer the type of the variable 10 | age = 25 11 | 12 | fmt.Println("Hello", userName, "you are", age, "years old") 13 | 14 | } -------------------------------------------------------------------------------- /docs/golang/concepts/5) userinput.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "os" 7 | ) 8 | 9 | func main() { 10 | 11 | // Using bufio package 12 | reader := bufio.NewReader(os.Stdin) 13 | fmt.Print("Enter text: ") 14 | text, _ := reader.ReadString('\n') // text, error syntax. We ignore the error by using _. 15 | fmt.Println(text) 16 | 17 | // Using fmt package 18 | var name string 19 | fmt.Print("Enter your name: ") 20 | fmt.Scan(&name) // Scan takes a pointer to a variable 21 | fmt.Println("Hello", name) 22 | } 23 | -------------------------------------------------------------------------------- /docs/golang/concepts/6) conversions.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | func main() { 9 | // Convert a string to an integer using strconv package 10 | numStr := "42" 11 | num, _ := strconv.Atoi(numStr) // num, _ syntax used to ignore the error. 12 | 13 | fmt.Printf("num: %d, type: %T\n", num, num) 14 | 15 | // Convert an integer to a string using strconv package 16 | num = 123 17 | numStr = strconv.Itoa(num) 18 | fmt.Printf("numStr: %s, type: %T\n", numStr, numStr) 19 | 20 | } 21 | -------------------------------------------------------------------------------- /docs/golang/concepts/6) math.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // import ( 4 | // "fmt" 5 | // "math/rand" 6 | // "time" 7 | // ) 8 | 9 | // func main() { 10 | // rand.Seed(time.Now().UnixNano()) // seed the random number generator. Time is used as seed to generate random numbers 11 | // fmt.Println(rand.Intn(100) +1) // generate random number between 1 and 100 12 | // } 13 | 14 | import ( 15 | "crypto/rand" 16 | "fmt" 17 | "math/big" 18 | ) 19 | 20 | func main() { 21 | myRandomNumber, _ := rand.Int(rand.Reader, big.NewInt(100)) // generate random number between 1 and 100 22 | fmt.Println(myRandomNumber) 23 | } 24 | -------------------------------------------------------------------------------- /docs/golang/concepts/6) string-opr.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | func main() { 9 | 10 | var name = "John" 11 | fmt.Println(len(name)) // It will print the length of the string 12 | fmt.Println(strings.ToUpper(name)) // It will print the string in uppercase 13 | fmt.Println(strings.ToLower(name)) // It will print the string in lowercase 14 | fmt.Println(strings.Title(name)) // It will print the string in title case 15 | fmt.Println(strings.Repeat(name, 3)) // It will repeat the string 3 times 16 | fmt.Println(strings.Replace(name, "J", "K", 1)) // It will replace the first occurrence of J with K 17 | fmt.Println(strings.Split(name, "")) // It will split the string into a slice of characters 18 | } 19 | -------------------------------------------------------------------------------- /docs/golang/concepts/7) time.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | 10 | presentTime := time.Now() 11 | fmt.Println("Present Time is: ", presentTime) 12 | fmt.Println("Present Time is: ", presentTime.Format("01-02-2006 Mon")) 13 | 14 | createdDate := time.Date(2020, time.August, 10, 23,23,0,0 , time.UTC) 15 | fmt.Println("Created Date is: ", createdDate) 16 | fmt.Println("Created Date is: ", createdDate.Format("01-02-2006 Mon")) 17 | } 18 | -------------------------------------------------------------------------------- /docs/golang/concepts/8) pointers.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main(){ 4 | 5 | // var ptr *int 6 | 7 | myInt := 42 8 | ptr := &myInt // & is used to get the address of the variable 9 | // var ptr *int = &myInt 10 | 11 | println("myInt:", ptr) // ptr is the address of the variable 12 | println("myInt:", *ptr) // * is used to get the value stored at the address 13 | 14 | } 15 | 16 | type Persons struct { 17 | Name string 18 | Age int 19 | } 20 | 21 | 22 | func ModifyPerson(p *Persons) { 23 | p.Name = "Alice" 24 | } -------------------------------------------------------------------------------- /docs/golang/concepts/code-org-with-packages/go.modddd: -------------------------------------------------------------------------------- 1 | module code-org 2 | 3 | go 1.19 4 | -------------------------------------------------------------------------------- /docs/golang/concepts/code-org-with-packages/hello/hello.go: -------------------------------------------------------------------------------- 1 | package hello 2 | 3 | import "fmt" 4 | 5 | func Hello() { // Function name starts with a capital letter so it is exported. It can be called from outside the package 6 | fmt.Println("Hello from hello.go") 7 | } -------------------------------------------------------------------------------- /docs/golang/concepts/code-org-with-packages/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "code-org/name" 5 | "code-org/hello" 6 | 7 | ) 8 | 9 | func main() { 10 | name.Name() //Name() functtion is exported so we can call it from outside the package 11 | hello.Hello() //Hello() functtion is exported so we can call it from outside the package 12 | wish() // Wish exists in the same package as main so we can call it directly without importing it 13 | } 14 | -------------------------------------------------------------------------------- /docs/golang/concepts/code-org-with-packages/name/name.go: -------------------------------------------------------------------------------- 1 | package name 2 | 3 | import "fmt" 4 | 5 | func Name() { 6 | fmt.Println("Hello from name.go") 7 | } 8 | 9 | -------------------------------------------------------------------------------- /docs/golang/concepts/code-org-with-packages/wish.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func wish(){ 4 | println("Hello from wish.go") 5 | } -------------------------------------------------------------------------------- /docs/golang/concepts/files/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "io/ioutil" 7 | "os" 8 | ) 9 | 10 | func main() { 11 | content := "Hello, playground!" 12 | 13 | file, err := os.Create("./test.txt") 14 | 15 | if err != nil { 16 | panic(err) 17 | } 18 | 19 | length, err := io.WriteString(file, content) 20 | 21 | if err != nil { 22 | panic(err) 23 | } 24 | fmt.Println("Length of the file is: ", length) 25 | defer file.Close() 26 | 27 | readFile("./test.txt") 28 | 29 | } 30 | 31 | func readFile(filename string){ 32 | 33 | databyte, err := ioutil.ReadFile(filename) 34 | 35 | if err != nil { 36 | panic(err) 37 | } 38 | 39 | fmt.Println("Text data inside a file is \n", string(databyte)) 40 | } 41 | -------------------------------------------------------------------------------- /docs/golang/concepts/files/test.txt: -------------------------------------------------------------------------------- 1 | Hello, playground! -------------------------------------------------------------------------------- /docs/golang/concepts/my-modules/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/Pradumnasaraf/DevOps 2 | 3 | go 1.19 4 | 5 | require github.com/gorilla/mux v1.8.0 6 | -------------------------------------------------------------------------------- /docs/golang/concepts/my-modules/go.sum: -------------------------------------------------------------------------------- 1 | github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= 2 | github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= 3 | -------------------------------------------------------------------------------- /docs/golang/concepts/my-modules/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net/http" 7 | "github.com/gorilla/mux" 8 | ) 9 | 10 | func main() { 11 | greeter() 12 | r := mux.NewRouter() 13 | r.HandleFunc("/", serverHome).Methods("GET") 14 | log.Fatal(http.ListenAndServe(":4000", r)) 15 | 16 | } 17 | 18 | func greeter() { 19 | fmt.Println("Hey there mod users") 20 | } 21 | 22 | func serverHome(w http.ResponseWriter,r *http.Request){ 23 | w.Write([]byte("

Hey welcome to Golang

")) 24 | 25 | } -------------------------------------------------------------------------------- /docs/golang/learning-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | title: Learning Resources 4 | description: A collection of resources to learn more about Golang. 5 | tags: ["Golang", "Programming", "Go"] 6 | keywords: ["Golang", "Programming", "Go"] 7 | slug: "/golang/resources" 8 | --- 9 | 10 | - [Go by Example](https://gobyexample.com/) 11 | - [Go Tour](https://tour.golang.org/welcome/1) 12 | - [Go Playground](https://play.golang.org/) 13 | - [Go Documentation](https://golang.org/doc/) 14 | - [Let's go with golang](https://youtube.com/playlist?list=PLRAV69dS1uWQGDQoBYMZWKjzuhCaOnBpa) - Recommended 15 | - [Golang Tutorial TechWorld with Nana](https://youtu.be/yyUHQIec83I) 16 | - [Codeacademy Free course](https://www.codecademy.com/learn/learn-go) 17 | - [Gophercises](https://gophercises.com/) 18 | 19 | 20 | -------------------------------------------------------------------------------- /docs/golang/other-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 3 3 | title: Other Resources 4 | description: A collection of resources to learn more about Golang. 5 | tags: ["Golang", "Programming", "DevOps"] 6 | keywords: ["Golang", "Programming", "DevOps"] 7 | slug: "/golang/other-resources" 8 | --- 9 | 10 | Here are list of other resources that you can refer to learn more about Golang: 11 | 12 | - [Apps](https://github.com/Pradumnasaraf/DevOps/tree/main/docs/golang/apps): Source code for the apps I build while learning Golang 13 | - [Concepts](https://github.com/Pradumnasaraf/DevOps/tree/main/docs/golang/concepts): Each Golang topic is break into seprate files to help better understand the concepts. -------------------------------------------------------------------------------- /docs/helm/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Helm", 3 | "position": 9 4 | } 5 | -------------------------------------------------------------------------------- /docs/helm/charts/minimal/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /docs/helm/charts/minimal/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: minimal 3 | description: A tiny helm chart for educational purposes 4 | type: application 5 | version: 0.1.0 6 | appVersion: 1.26.0 7 | -------------------------------------------------------------------------------- /docs/helm/charts/minimal/templates/NOTES.txt: -------------------------------------------------------------------------------- 1 | Hi 👋 -- you just deployed {{ template "envShort" . }} -------------------------------------------------------------------------------- /docs/helm/charts/minimal/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{- define "envShort" -}} 2 | {{- if eq .Values.environment "production" -}} 3 | prod 4 | {{- else -}} 5 | non-prod 6 | {{- end -}} 7 | {{- end -}} 8 | -------------------------------------------------------------------------------- /docs/helm/charts/minimal/templates/configmap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: helm-{{ .Release.Name }}-configmap 5 | data: 6 | appVersion: {{ .Chart.AppVersion }} 7 | environment: {{ .Values.environment | quote }} 8 | envShort: {{ template "envShort" . }} 9 | {{- range .Values.configData }} 10 | {{- if .enabled }} 11 | {{ .key }}: {{ .value | quote }} 12 | {{- end }} 13 | {{- end }} -------------------------------------------------------------------------------- /docs/helm/charts/minimal/values-alt.yaml: -------------------------------------------------------------------------------- 1 | environment: staging 2 | 3 | configData: 4 | - key: conditionalKey 5 | value: "this wont be included" 6 | enabled: false 7 | -------------------------------------------------------------------------------- /docs/helm/charts/minimal/values.yaml: -------------------------------------------------------------------------------- 1 | environment: production 2 | 3 | configData: 4 | - key: conditionalKey 5 | value: "this will be included" 6 | enabled: true 7 | -------------------------------------------------------------------------------- /docs/helm/learning-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | title: Learning Resources 4 | description: A collection of resources to learn more about Helm. 5 | tags: ["Helm", "Kubernetes", "DevOps"] 6 | keywords: ["Helm", "Kubernetes", "DevOps"] 7 | slug: "/helm/resources" 8 | --- 9 | 10 | - [Helm Docs](https://helm.sh/) 11 | - [ Helm for beginers](https://www.youtube.com/watch?v=KeRrvCrF8zc) 12 | - [ Helm in Depth ](https://www.youtube.com/watch?v=gbUBTTXuQwI&list=PLLYW3zEOaqlKYku0piyzzLFGpR9VpPvXR) 13 | -------------------------------------------------------------------------------- /docs/jenkins/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Jenkins", 3 | "position": 15 4 | } 5 | -------------------------------------------------------------------------------- /docs/jenkins/docker-setup/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM jenkins/jenkins:2.375.1 2 | USER root 3 | RUN apt-get update && apt-get install -y lsb-release 4 | RUN curl -fsSLo /usr/share/keyrings/docker-archive-keyring.asc \ 5 | https://download.docker.com/linux/debian/gpg 6 | RUN echo "deb [arch=$(dpkg --print-architecture) \ 7 | signed-by=/usr/share/keyrings/docker-archive-keyring.asc] \ 8 | https://download.docker.com/linux/debian \ 9 | $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list 10 | RUN apt-get update && apt-get install -y docker-ce-cli 11 | USER jenkins 12 | RUN jenkins-plugin-cli --plugins "blueocean:1.26.0 docker-workflow:563.vd5d2e5c4007f" -------------------------------------------------------------------------------- /docs/jenkins/docker-setup/dind.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker run \ 4 | --name jenkins-docker \ 5 | --detach \ 6 | --privileged \ 7 | --network jenkins \ 8 | --network-alias docker \ 9 | --env DOCKER_TLS_CERTDIR=/certs \ 10 | --volume jenkins-docker-certs:/certs/client \ 11 | --volume jenkins-data:/var/jenkins_home \ 12 | --publish 2376:2376 \ 13 | docker:dind \ 14 | --storage-driver overlay2 -------------------------------------------------------------------------------- /docs/jenkins/docker-setup/jenkins.sh: -------------------------------------------------------------------------------- 1 | docker run \ 2 | --name jenkins-blueocean \ 3 | --restart=on-failure \ 4 | --detach \ 5 | --network jenkins \ 6 | --env DOCKER_HOST=tcp://docker:2376 \ 7 | --env DOCKER_CERT_PATH=/certs/client \ 8 | --env DOCKER_TLS_VERIFY=1 \ 9 | --publish 8080:8080 \ 10 | --publish 50000:50000 \ 11 | --volume jenkins-data:/var/jenkins_home \ 12 | --volume jenkins-docker-certs:/certs/client:ro \ 13 | myjenkins-blueocean:2.375.1-1 -------------------------------------------------------------------------------- /docs/jenkins/jenkinsfiles/Jenkinsfile: -------------------------------------------------------------------------------- 1 | def gv 2 | pipeline{ 3 | agent any 4 | stages{ 5 | stage('init Groovy Script'){ 6 | steps{ 7 | script{ 8 | gv = load 'script.groovy' 9 | } 10 | } 11 | } 12 | stage('Build'){ 13 | steps{ 14 | script{ 15 | gv.buildApp() 16 | } 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /docs/jenkins/jenkinsfiles/Jenkinsfile-multistage: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent any 3 | stages { 4 | stage('Build') { 5 | steps { 6 | sh 'docker build -t jenkins-docker .' 7 | } 8 | } 9 | stage('Test') { 10 | steps { 11 | sh 'docker run jenkins-docker' 12 | } 13 | } 14 | stage('Deploy') { 15 | steps { 16 | sh 'docker push jenkins-docker' 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /docs/jenkins/jenkinsfiles/Jenkinsfile-para: -------------------------------------------------------------------------------- 1 | pipeline{ 2 | agent any 3 | parameters{ // Parameters are defined here 4 | booleanParam(name: 'executeTest', defaultValue: true, description: 'Execute Test?') 5 | } 6 | stages{ 7 | stage('Check'){ 8 | stage { 9 | expression(){ 10 | params.executeTest == true 11 | } 12 | } 13 | steps{ 14 | echo "Execute Test: ${params.executeTest}" // Accessing the parameters by params.{parameter_name} 15 | sh 'docker run jenkins-docker' 16 | } 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /docs/jenkins/jenkinsfiles/script.groovy: -------------------------------------------------------------------------------- 1 | def testApp() { 2 | sh 'echo "Test"' 3 | } 4 | def buildApp() { 5 | sh 'echo "Build"' 6 | } 7 | def deployApp() { 8 | sh 'echo "Deploy"' 9 | } 10 | 11 | return this 12 | -------------------------------------------------------------------------------- /docs/jenkins/learning-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | title: Learning Resources 4 | description: A collection of resources to learn more about Jenkins. 5 | tags: ["Jenkins", "Continuous Integration", "Continuous Delivery", "DevOps"] 6 | keywords: ["Jenkins", "Continuous Integration", "Continuous Delivery", "DevOps"] 7 | slug: "/jenkins/resources" 8 | --- 9 | 10 | ### Resources 11 | 12 | - [official documentation](https://www.jenkins.io/doc/) 13 | - [Jenkins Docker Installation (docs)](https://www.jenkins.io/doc/book/installing/docker/) 14 | - [Jenkins Tutorial - TechWorld with Nana (video)](https://www.youtube.com/playlist?list=PLy7NrYWoggjw_LIiDK1LXdNN82uYuuuiC) 15 | - [Jenkins FreeCodeCamp (video)](https://youtu.be/f4idgaq2VqA) -------------------------------------------------------------------------------- /docs/kubernetes/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Kubernetes", 3 | "position": 3 4 | } 5 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/deployment-strategies/Namespcae.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: deployment-strategies -------------------------------------------------------------------------------- /docs/kubernetes/apps/deployment-strategies/Recreate.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | namespace: deployment-strategies 5 | name: rollingupdate-deployment 6 | spec: 7 | strategy: 8 | type: Recreate 9 | replicas: 10 10 | selector: 11 | matchLabels: 12 | app: rollingupdate-app 13 | template: 14 | metadata: 15 | labels: 16 | app: rollingupdate-app 17 | spec: 18 | containers: 19 | - name: nginx-app 20 | image: pradumnasaraf/nginx:green 21 | # image: pradumnasaraf/nginx:blue 22 | ports: 23 | - name: http 24 | containerPort: 80 25 | startupProbe: 26 | httpGet: 27 | port: 80 28 | initialDelaySeconds: 20 29 | periodSeconds: 5 30 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/deployment-strategies/RollingUpdate.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | namespace: deployment-strategies 5 | name: rollingupdate-deployment 6 | spec: 7 | strategy: 8 | type: RollingUpdate # This is the default 9 | rollingUpdate: 10 | maxUnavailable: 25% # Maximum number of pods that can be unavailable during the update 11 | # maxUnavailable: 1 # We can also provide a fix number of pods instead of percentage 12 | maxSurge: 25% # Maximum number of pods that can be created above the desired number of pods 13 | # maxSurge: 1 # We can also provide a fix number of pods instead of percentage 14 | replicas: 10 15 | selector: 16 | matchLabels: 17 | app: rollingupdate-app 18 | template: 19 | metadata: 20 | labels: 21 | app: rollingupdate-app 22 | spec: 23 | containers: 24 | - name: nginx-app 25 | # image: pradumnasaraf/nginx:green 26 | image: pradumnasaraf/nginx:blue 27 | ports: 28 | - name: http 29 | containerPort: 80 30 | startupProbe: 31 | httpGet: 32 | port: 80 33 | initialDelaySeconds: 20 34 | periodSeconds: 5 35 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/deployment-strategies/blue-green/Blue.Deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | namespace: deployment-strategies 5 | name: blue-deployment 6 | spec: 7 | replicas: 4 8 | selector: 9 | matchLabels: 10 | app: nginx-app 11 | replica: blue 12 | template: 13 | metadata: 14 | labels: 15 | app: nginx-app 16 | replica: blue 17 | spec: 18 | containers: 19 | - name: nginx-app 20 | image: pradumnasaraf/nginx:blue 21 | ports: 22 | - name: http 23 | containerPort: 80 24 | startupProbe: 25 | httpGet: 26 | port: 80 27 | initialDelaySeconds: 20 28 | periodSeconds: 5 29 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/deployment-strategies/blue-green/Green.Deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | namespace: deployment-strategies 5 | name: green-deployment 6 | spec: 7 | replicas: 4 8 | selector: 9 | matchLabels: 10 | app: nginx-app 11 | replica: green 12 | template: 13 | metadata: 14 | labels: 15 | app: nginx-app 16 | replica: green 17 | spec: 18 | containers: 19 | - name: nginx-app 20 | image: pradumnasaraf/nginx:green 21 | ports: 22 | - name: http 23 | containerPort: 80 24 | startupProbe: 25 | httpGet: 26 | port: 80 27 | initialDelaySeconds: 20 28 | periodSeconds: 5 29 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/deployment-strategies/blue-green/Service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | namespace: deployment-strategies 5 | name: blue-green-service 6 | spec: 7 | type: ClusterIP 8 | selector: 9 | app: nginx-app 10 | replica: green 11 | ports: 12 | - protocol: TCP 13 | port: 80 14 | targetPort: 80 -------------------------------------------------------------------------------- /docs/kubernetes/apps/deployment-strategies/canary/Canray.Deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | namespace: deployment-strategies 5 | name: my-nginx-deployment 6 | spec: 7 | replicas: 5 8 | selector: 9 | matchLabels: 10 | app: nginx-app 11 | template: 12 | metadata: 13 | labels: 14 | app: nginx-app 15 | spec: 16 | containers: 17 | - name: nginx-app 18 | image: pradumnasaraf/nginx:green 19 | ports: 20 | - name: http 21 | containerPort: 80 22 | startupProbe: 23 | httpGet: 24 | port: 80 25 | initialDelaySeconds: 20 26 | periodSeconds: 5 27 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/deployment-strategies/canary/Deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | namespace: deployment-strategies 5 | name: my-nginx-deployment 6 | spec: 7 | replicas: 10 8 | selector: 9 | matchLabels: 10 | app: nginx-app 11 | template: 12 | metadata: 13 | labels: 14 | app: nginx-app 15 | spec: 16 | containers: 17 | - name: nginx-app 18 | image: pradumnasaraf/nginx:blue 19 | ports: 20 | - name: http 21 | containerPort: 80 22 | startupProbe: 23 | httpGet: 24 | port: 80 25 | initialDelaySeconds: 20 26 | periodSeconds: 5 27 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/deployment-strategies/canary/Service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | namespace: deployment-strategies 5 | name: canary-service 6 | spec: 7 | type: ClusterIP 8 | selector: 9 | app: nginx-app 10 | ports: 11 | - protocol: TCP 12 | port: 80 13 | targetPort: 80 -------------------------------------------------------------------------------- /docs/kubernetes/apps/drupal-postgres/Drupal.Deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: drupal-deployment 5 | namespace: drupal 6 | spec: 7 | replicas: 3 8 | selector: 9 | matchLabels: 10 | app: drupal-app 11 | template: 12 | metadata: 13 | labels: 14 | app: drupal-app 15 | spec: 16 | containers: 17 | - name: drupal 18 | image: drupal:11 19 | ports: 20 | - containerPort: 80 21 | resources: 22 | limits: 23 | memory: "250Mi" 24 | cpu: "250m" 25 | requests: 26 | memory: "250Mi" 27 | cpu: "250m" 28 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/drupal-postgres/Drupal.Service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: drupal-service 5 | namespace: drupal 6 | spec: 7 | selector: 8 | app: drupal-app 9 | ports: 10 | - port: 80 11 | targetPort: 80 12 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/drupal-postgres/Namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: drupal -------------------------------------------------------------------------------- /docs/kubernetes/apps/drupal-postgres/Postgres.Deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: postgres-deployment 5 | namespace: drupal 6 | spec: 7 | selector: 8 | matchLabels: 9 | app: postgres-app 10 | template: 11 | metadata: 12 | labels: 13 | app: postgres-app 14 | spec: 15 | containers: 16 | - name: postgres 17 | image: postgres:16 18 | ports: 19 | - containerPort: 5432 20 | env: 21 | - name: POSTGRES_USER 22 | valueFrom: 23 | secretKeyRef: 24 | name: postgres-secrets 25 | key: psql-username 26 | - name: POSTGRES_PASSWORD 27 | valueFrom: 28 | secretKeyRef: 29 | name: postgres-secrets 30 | key: psql-password 31 | volumeMounts: 32 | - name: postgres-persistent-storage 33 | mountPath: /var/lib/postgresql/data 34 | 35 | volumes: 36 | - name: postgres-persistent-storage 37 | persistentVolumeClaim: 38 | claimName: postgres-pvc -------------------------------------------------------------------------------- /docs/kubernetes/apps/drupal-postgres/Postgres.PV.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolume 3 | metadata: 4 | name: postgres-pv 5 | namespace: drupal 6 | labels: 7 | type: local 8 | spec: 9 | capacity: 10 | storage: 250Mi 11 | storageClassName : manual 12 | volumeMode: Filesystem 13 | accessModes: 14 | - ReadWriteOnce 15 | hostPath: 16 | path: "/mnt/data/drupal-app/postgres-pv" 17 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/drupal-postgres/Postgres.PVC.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolumeClaim 3 | metadata: 4 | name: postgres-pvc 5 | namespace: drupal 6 | spec: 7 | resources: 8 | requests: 9 | storage: 250Mi 10 | storageClassName: manual 11 | volumeMode: Filesystem 12 | accessModes: 13 | - ReadWriteOnce 14 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/drupal-postgres/Postgres.Secrets.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: postgres-secrets 5 | namespace: drupal 6 | type: Opaque 7 | data: 8 | psql-username: dXNlcm5hbWU= 9 | psql-password: cGFzc3dvcmQ= 10 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/drupal-postgres/Postgres.Service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: postgres-service 5 | namespace: drupal 6 | spec: 7 | selector: 8 | app: postgres-app 9 | ports: 10 | - port: 5432 11 | targetPort: 5432 12 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/go-node-react-postgres/Namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: demo-app 5 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/go-node-react-postgres/api-golang/Deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: api-golang 5 | namespace: demo-app 6 | labels: 7 | app: api-golang 8 | spec: 9 | replicas: 1 10 | selector: 11 | matchLabels: 12 | app: api-golang 13 | template: 14 | metadata: 15 | labels: 16 | app: api-golang 17 | spec: 18 | containers: 19 | - name: api-golang 20 | image: sidpalas/devops-directive-docker-course-api-golang:foobarbaz 21 | env: 22 | - name: PORT 23 | value: "8000" 24 | envFrom: 25 | - secretRef: 26 | name: api-golang-database-url 27 | ports: 28 | - containerPort: 8000 29 | protocol: TCP 30 | readinessProbe: 31 | httpGet: 32 | path: /ping 33 | port: 8000 34 | resources: 35 | limits: 36 | memory: "100Mi" 37 | requests: 38 | memory: "100Mi" 39 | cpu: "50m" 40 | securityContext: 41 | allowPrivilegeEscalation: false 42 | privileged: false 43 | securityContext: 44 | seccompProfile: 45 | type: RuntimeDefault 46 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/go-node-react-postgres/api-golang/IngressRoute.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: traefik.containo.us/v1alpha1 2 | kind: IngressRoute 3 | metadata: 4 | name: api-golang 5 | namespace: demo-app 6 | spec: 7 | entryPoints: 8 | - web 9 | routes: 10 | - kind: Rule 11 | match: Host(`d11ae95f-7695-4635-9637-13829bf55c83.lb.civo.com`) && PathPrefix(`/api/golang`) 12 | middlewares: 13 | - name: strip-api-prefixes 14 | services: 15 | - kind: Service 16 | name: api-golang 17 | port: 8000 18 | scheme: http 19 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/go-node-react-postgres/api-golang/Secret.yml: -------------------------------------------------------------------------------- 1 | # ⛔️ DONT PUT SECRET FILES IN VCS 2 | apiVersion: v1 3 | kind: Secret 4 | type: Opaque 5 | metadata: 6 | name: api-golang-database-url 7 | namespace: demo-app 8 | stringData: 9 | DATABASE_URL: postgres://postgres:foobarbaz@postgres-postgresql.postgres.svc.cluster.local:5432/postgres 10 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/go-node-react-postgres/api-golang/Service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: api-golang 5 | namespace: demo-app 6 | spec: 7 | selector: 8 | app: api-golang 9 | ports: 10 | - protocol: TCP 11 | port: 8000 12 | targetPort: 8000 13 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/go-node-react-postgres/api-node/Deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: api-node 5 | namespace: demo-app 6 | labels: 7 | app: api-node 8 | spec: 9 | replicas: 1 10 | selector: 11 | matchLabels: 12 | app: api-node 13 | template: 14 | metadata: 15 | labels: 16 | app: api-node 17 | spec: 18 | containers: 19 | - name: api-node 20 | image: sidpalas/devops-directive-docker-course-api-node:foobarbaz 21 | env: 22 | - name: PORT 23 | value: "3000" 24 | envFrom: 25 | - secretRef: 26 | name: api-node-database-url 27 | ports: 28 | - containerPort: 3000 29 | protocol: TCP 30 | readinessProbe: 31 | httpGet: 32 | path: /ping 33 | port: 3000 34 | resources: 35 | limits: 36 | memory: "100Mi" 37 | requests: 38 | memory: "100Mi" 39 | cpu: "50m" 40 | securityContext: 41 | allowPrivilegeEscalation: false 42 | privileged: false 43 | securityContext: 44 | seccompProfile: 45 | type: RuntimeDefault 46 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/go-node-react-postgres/api-node/IngressRoute.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: traefik.containo.us/v1alpha1 2 | kind: IngressRoute 3 | metadata: 4 | name: api-node 5 | namespace: demo-app 6 | spec: 7 | entryPoints: 8 | - web 9 | routes: 10 | - kind: Rule 11 | match: Host(`d11ae95f-7695-4635-9637-13829bf55c83.lb.civo.com`) && PathPrefix(`/api/node`) 12 | middlewares: 13 | - name: strip-api-prefixes 14 | services: 15 | - kind: Service 16 | name: api-node 17 | port: 3000 18 | scheme: http 19 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/go-node-react-postgres/api-node/Secret.yaml: -------------------------------------------------------------------------------- 1 | # ⛔️ DONT PUT SECRET FILES IN VCS 2 | apiVersion: v1 3 | kind: Secret 4 | type: Opaque 5 | metadata: 6 | name: api-node-database-url 7 | namespace: demo-app 8 | stringData: 9 | DATABASE_URL: postgres://postgres:foobarbaz@postgres-postgresql.postgres.svc.cluster.local:5432/postgres 10 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/go-node-react-postgres/api-node/Service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: api-node 5 | namespace: demo-app 6 | spec: 7 | selector: 8 | app: api-node 9 | ports: 10 | - protocol: TCP 11 | port: 3000 12 | targetPort: 3000 13 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/go-node-react-postgres/client-react/ConfigMap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: nginx-conf 5 | namespace: demo-app 6 | data: 7 | default.conf: |- 8 | server { 9 | listen 8080; 10 | 11 | location /ping { 12 | access_log off; 13 | add_header 'Content-Type' 'text/plain'; 14 | return 200 "pong"; 15 | } 16 | 17 | location / { 18 | root /usr/share/nginx/html; 19 | index index.html index.htm; 20 | try_files $uri $uri/ /index.html =404; 21 | } 22 | 23 | include /etc/nginx/extra-conf.d/*.conf; 24 | } 25 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/go-node-react-postgres/client-react/IngressRoute.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: traefik.containo.us/v1alpha1 2 | kind: IngressRoute 3 | metadata: 4 | name: client-react-nginx 5 | namespace: demo-app 6 | spec: 7 | entryPoints: 8 | - web 9 | routes: 10 | - kind: Rule 11 | match: Host(`d11ae95f-7695-4635-9637-13829bf55c83.lb.civo.com`) 12 | services: 13 | - kind: Service 14 | name: client-react-nginx 15 | port: 8080 16 | scheme: http 17 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/go-node-react-postgres/client-react/Service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: client-react-nginx 5 | namespace: demo-app 6 | spec: 7 | selector: 8 | app: client-react-nginx 9 | ports: 10 | - protocol: TCP 11 | port: 8080 12 | targetPort: 8080 13 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/go-node-react-postgres/common/Middleware.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: traefik.containo.us/v1alpha1 2 | kind: Middleware 3 | metadata: 4 | name: strip-api-prefixes 5 | namespace: demo-app 6 | spec: 7 | stripPrefix: 8 | forceSlash: false 9 | prefixes: 10 | - /api/node 11 | - /api/golang 12 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/go-node-react-postgres/common/Namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: demo-app 5 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/go-node-react-postgres/postgresql/Job.db-migrator.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: batch/v1 2 | kind: Job 3 | metadata: 4 | name: db-migrator 5 | namespace: demo-app 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: migrate 11 | image: sidpalas/devops-directive-kubernetes-course-db-migrator:foobarbaz 12 | args: 13 | - -path=/app/migrations 14 | - -database=$(DATABASE_URL)?sslmode=disable 15 | - up 16 | envFrom: 17 | - secretRef: 18 | name: db-password 19 | restartPolicy: OnFailure 20 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/go-node-react-postgres/postgresql/Secret.db-password.yaml: -------------------------------------------------------------------------------- 1 | # ⛔️ DONT PUT SECRET FILES IN VCS 2 | apiVersion: v1 3 | kind: Secret 4 | metadata: 5 | name: db-password 6 | namespace: demo-app 7 | type: Opaque 8 | stringData: 9 | DATABASE_URL: postgres://postgres:foobarbaz@postgres-postgresql.postgres.svc.cluster.local:5432/postgres # postgres://username:password@..svc.cluster.local:5432/postgres 10 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/go-node-react-postgres/postgresql/values.yaml: -------------------------------------------------------------------------------- 1 | primary: 2 | resources: 3 | limits: 4 | ephemeral-storage: 1Gi 5 | memory: 500Mi 6 | requests: 7 | cpu: 100m 8 | ephemeral-storage: 50Mi 9 | memory: 128Mi 10 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/mongo-express/MongoDB.Configmap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: mongodb-configmap 5 | namespace: mongo-express 6 | data: 7 | database_url: mongodb-service # mongodb service name -------------------------------------------------------------------------------- /docs/kubernetes/apps/mongo-express/MongoDB.Deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: mongodb-deployment 5 | namespace: mongo-express 6 | labels: 7 | app: mongodb 8 | spec: 9 | replicas: 1 10 | selector: 11 | matchLabels: 12 | app: mongodb 13 | template: 14 | metadata: 15 | labels: 16 | app: mongodb 17 | spec: 18 | containers: 19 | - name: mongodb 20 | image: mongo:8.0 21 | ports: 22 | - containerPort: 27017 23 | env: 24 | - name: MONGO_INITDB_ROOT_USERNAME 25 | valueFrom: 26 | secretKeyRef: 27 | name: mongodb-secret 28 | key: mongo-root-username 29 | - name: MONGO_INITDB_ROOT_PASSWORD 30 | valueFrom: 31 | secretKeyRef: 32 | name: mongodb-secret 33 | key: mongo-root-password 34 | resources: 35 | limits: 36 | memory: "250Mi" 37 | cpu: "250m" 38 | requests: 39 | memory: "250Mi" 40 | cpu: "250m" 41 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/mongo-express/MongoDB.Secret.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: mongodb-secret 5 | namespace: mongo-express 6 | type: Opaque 7 | data: 8 | mongo-root-username: YWRtaW4= # Decodes to "admin" 9 | mongo-root-password: cGFzc3dvcmQ= # Decodes to "password" 10 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/mongo-express/MongoDB.Service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: mongodb-service 5 | namespace: mongo-express 6 | spec: 7 | selector: 8 | app: mongodb 9 | ports: 10 | - protocol: TCP 11 | port: 27017 12 | targetPort: 27017 -------------------------------------------------------------------------------- /docs/kubernetes/apps/mongo-express/MongoExpress.Secret.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: mongo-express-secret 5 | namespace: mongo-express 6 | type: Opaque 7 | data: 8 | auth-username: YWRtaW4= # Decodes to "admin" 9 | auth-password: cGFzc3dvcmQ= # Decodes to "password" 10 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/mongo-express/MongoExpress.Service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: mongodb-express-service 5 | namespace: mongo-express 6 | spec: 7 | selector: 8 | app: mongodb-express 9 | ports: 10 | - protocol: TCP 11 | port: 8081 12 | targetPort: 8081 13 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/mongo-express/Namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: mongo-express -------------------------------------------------------------------------------- /docs/kubernetes/apps/multi-container/alpine.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: alpine-deployment 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: alpine 9 | template: 10 | metadata: 11 | labels: 12 | app: alpine 13 | spec: 14 | containers: 15 | - name: nginx 16 | image: nginx 17 | ports: 18 | - containerPort: 80 19 | - name: alpine 20 | image: alpine 21 | command: ["bin/sh"] 22 | args: ["-c", "echo Hello from the alpine container! && apk add curl && sleep 3600"] 23 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/multi-container/curlimage.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: myapp 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: myapp 9 | template: 10 | metadata: 11 | labels: 12 | app: myapp 13 | spec: 14 | containers: 15 | - name: nginx 16 | image: nginx 17 | ports: 18 | - containerPort: 80 19 | - name: sidecar 20 | image: curlimages/curl 21 | command: ["bin/sh"] 22 | args: ["-c", "echo Hello from the sidecar container! && sleep 3600"] 23 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/nginx-custom/ConfigMap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: nginx-configmap 5 | data: 6 | index.html: | 7 |

Hello World from ConfigMap

8 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/nginx-custom/Deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: nginx-deployment 5 | namespace: nginx-demo 6 | spec: 7 | replicas: 3 8 | selector: 9 | matchLabels: 10 | app: nginx-app 11 | template: 12 | metadata: 13 | labels: 14 | app: nginx-app 15 | spec: 16 | containers: 17 | - name: nginx 18 | image: nginx:latest 19 | ports: 20 | - containerPort: 80 21 | resources: 22 | limits: 23 | cpu: 100m 24 | memory: 100Mi 25 | requests: 26 | cpu: 100m 27 | memory: 100Mi 28 | readinessProbe: 29 | failureThreshold: 3 30 | httpGet: 31 | path: / 32 | port: 80 33 | volumeMounts: 34 | - name: html-file 35 | mountPath: /usr/share/nginx/html 36 | 37 | volumes: 38 | - name: html-file 39 | configMap: 40 | name: nginx-configmap 41 | 42 | 43 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/nginx-custom/Namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: nginx-demo 5 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/nginx-custom/Service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: nginx-service-clusterip 5 | namespace: nginx-demo 6 | spec: 7 | selector: 8 | app: nginx-app 9 | ports: 10 | - port: 80 11 | targetPort: 80 12 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/nginx-simple-app/Deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: nginx-deployment 5 | namespace: nginx-ns 6 | spec: 7 | selector: 8 | matchLabels: 9 | app: nginx-app 10 | template: 11 | metadata: 12 | labels: 13 | app: nginx-app 14 | spec: 15 | containers: 16 | - name: nginx 17 | image: nginx:latest 18 | resources: 19 | limits: 20 | memory: "128Mi" 21 | cpu: "500m" 22 | requests: 23 | memory: "64Mi" 24 | cpu: "250m" 25 | ports: 26 | - containerPort: 80 27 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/nginx-simple-app/Namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: nginx-ns -------------------------------------------------------------------------------- /docs/kubernetes/apps/nginx-simple-app/Service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: nginx-service-lb 5 | namespace: nginx-ns 6 | spec: 7 | type: LoadBalancer 8 | selector: 9 | app: nginx-app 10 | ports: 11 | - name: nginx 12 | protocol: TCP 13 | port: 80 14 | targetPort: 80 15 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/statefulset/service-nginx-headless.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: nginxs # Plural because it sets up DNS for each replica in the StatefulSet (e.g. nginx-0.nginxs.default.svc.cluster.local) 5 | spec: 6 | type: ClusterIP 7 | clusterIP: None # This makes it a "headless" service 8 | selector: 9 | app: nginx 10 | ports: 11 | - protocol: TCP 12 | port: 80 13 | targetPort: 80 14 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/statefulset/service-nginx.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: nginx # singular since it points to a single cluster IP 5 | spec: 6 | type: ClusterIP 7 | selector: 8 | app: nginx 9 | ports: 10 | - protocol: TCP 11 | port: 80 12 | targetPort: 80 13 | 14 | -------------------------------------------------------------------------------- /docs/kubernetes/apps/statefulset/stateful.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: StatefulSet 3 | metadata: 4 | name: nginx-with-init-containers 5 | spec: 6 | serviceName: nginxs # Headless service 7 | replicas: 3 8 | selector: 9 | matchLabels: 10 | app: nginx-app 11 | template: 12 | metadata: 13 | labels: 14 | app: nginx-app 15 | spec: 16 | initContainers: 17 | - name: populate-default-html 18 | image: nginx:1.26.0 19 | command: 20 | - bash 21 | - "-c" 22 | - | 23 | set -ex 24 | [[ $HOSTNAME =~ -([0-9]+)$ ]] || exit 1 25 | ordinal=${BASH_REMATCH[1]} 26 | echo "

Hello from pod $ordinal

" > /usr/share/nginx/html/index.html 27 | volumeMounts: 28 | - name: data 29 | mountPath: /usr/share/nginx/html 30 | containers: 31 | - name: nginx 32 | image: nginx:1.26.0 33 | volumeMounts: 34 | - name: data 35 | mountPath: /usr/share/nginx/html 36 | 37 | volumeClaimTemplates: # PersistentVolumeClaim templates for each replica 38 | - metadata: 39 | name: data 40 | spec: 41 | accessModes: ["ReadWriteOnce"] 42 | storageClassName: "standard" 43 | resources: 44 | requests: 45 | storage: 100Mi 46 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/configmap/configmap-file.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: file-like-keys 5 | data: 6 | conf.yml: | 7 | name: YourAppName 8 | version: 1.0.0 9 | author: YourName 10 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/configmap/configmap-keys.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: property-like-keys 5 | data: 6 | NAME: YourAppName 7 | VERSION: 1.0.0 8 | AUTHOR: YourName 9 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/configmap/pod-configmap-file.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: configmap-example-file 5 | spec: 6 | containers: 7 | - name: nginx 8 | image: nginx:1.26.0 9 | volumeMounts: 10 | - name: configmap-file-like-keys 11 | mountPath: /etc/config 12 | volumes: 13 | - name: configmap-file-like-keys 14 | configMap: 15 | name: file-like-keys 16 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/configmap/pod-configmap-key.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: configmap-example-key 5 | spec: 6 | containers: 7 | - name: nginx 8 | image: nginx:1.26.0 9 | envFrom: 10 | - configMapRef: 11 | name: property-like-keys 12 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/crds/trivy.txt: -------------------------------------------------------------------------------- 1 | ### Trivy 2 | 3 | Trivy helps to detect vulnerabilities in your application's dependencies. It is a simple and comprehensive vulnerability scanner for containers and other artifacts. 4 | 5 | #### Installation 6 | 7 | To install Trivy, you can use the following Helm chart: 8 | 9 | ```bash 10 | helm repo add aqua https://aquasecurity.github.io/helm-charts/ 11 | helm repo update 12 | helm install trivy-operator aqua/trivy-operator --namespace trivy-system --create-namespace --version 0.23.2 13 | ``` 14 | 15 | #### Uninstallation 16 | 17 | To uninstall Trivy, you can use the following Helm command: 18 | 19 | ```bash 20 | helm uninstall trivy-operator --namespace trivy-system 21 | ``` 22 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/cronjob/cronjob.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: batch/v1 2 | kind: CronJob 3 | metadata: 4 | name: echo-date-better 5 | spec: 6 | schedule: "* * * * *" 7 | jobTemplate: 8 | spec: 9 | parallelism: 1 10 | completions: 1 11 | activeDeadlineSeconds: 100 12 | backoffLimit: 1 13 | template: 14 | metadata: 15 | labels: 16 | app: echo-date 17 | spec: 18 | containers: 19 | - name: echo 20 | image: cgr.dev/chainguard/busybox:latest 21 | command: [date] 22 | resources: 23 | requests: 24 | memory: "64Mi" 25 | cpu: "250m" 26 | limits: 27 | memory: "64Mi" 28 | cpu: "250m" 29 | securityContext: 30 | allowPrivilegeEscalation: false 31 | privileged: false 32 | runAsUser: 1001 33 | runAsGroup: 1001 34 | runAsNonRoot: true 35 | restartPolicy: Never 36 | securityContext: 37 | seccompProfile: 38 | type: RuntimeDefault -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/daemonset/daemonset-nginx.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: DaemonSet 3 | metadata: 4 | name: nginx-daemonset 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: nginx-app 9 | template: 10 | metadata: 11 | labels: 12 | app: nginx-app 13 | spec: 14 | containers: 15 | - name: nginx 16 | image: nginx:1.26.0 -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/daemonset/daemonset.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: DaemonSet 3 | metadata: 4 | name: fluentd-daemonset 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: fluentd-app 9 | template: 10 | metadata: 11 | labels: 12 | app: fluentd-app 13 | spec: 14 | containers: 15 | - name: fluentd 16 | image: fluentd:v1.16-1 -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/deployment/deployment-best-pratices.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: nginx-better 5 | # namespace: nginx-better-deployment 6 | spec: 7 | replicas: 3 8 | selector: 9 | matchLabels: 10 | app: nginx-better 11 | template: 12 | metadata: 13 | labels: 14 | app: nginx-better 15 | spec: 16 | containers: 17 | - name: nginx 18 | image: cgr.dev/chainguard/nginx:latest 19 | ports: 20 | - containerPort: 8080 21 | protocol: TCP 22 | readinessProbe: 23 | httpGet: 24 | path: / 25 | port: 8080 26 | resources: 27 | requests: 28 | memory: "50Mi" # 50 M 29 | cpu: "250m" # 250 milliCPU 30 | limits: 31 | memory: "50Mi" 32 | cpu: "250m" 33 | securityContext: 34 | allowPrivilegeEscalation: false 35 | privileged: false 36 | securityContext: 37 | seccompProfile: 38 | type: RuntimeDefault 39 | runAsUser: 1000 40 | runAsGroup: 1001 41 | runAsNonRoot: true 42 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/deployment/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: nginx-minimal 5 | spec: 6 | replicas: 3 7 | selector: 8 | matchLabels: 9 | app: nginx-minimal 10 | template: 11 | metadata: 12 | labels: 13 | app: nginx-minimal 14 | spec: 15 | containers: 16 | - name: nginx 17 | image: nginx:1.26.0 18 | ports: 19 | - containerPort: 80 -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/gatewayapi/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: nginx-gateway-deployment 5 | spec: 6 | replicas: 3 7 | selector: 8 | matchLabels: 9 | app: nginx-app 10 | template: 11 | metadata: 12 | labels: 13 | app: nginx-app 14 | spec: 15 | containers: 16 | - name: nginx 17 | image: nginx:1.26.0 -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/gatewayapi/gateway-httproute.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1alpha1 2 | kind: HTTPRoute 3 | metadata: 4 | name: nginx-gateway-httproute 5 | spec: 6 | parentRefs: 7 | - name: nginx-gateway 8 | hostnames: 9 | - example.com 10 | rules: 11 | - matches: 12 | - path: 13 | type: Prefix 14 | value: / 15 | backend: 16 | - name: nginx-gateway-service 17 | servicePort: 80 -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/gatewayapi/gateway.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: gateway.networking.k8s.io/v1beta1 2 | kind: Gateway 3 | metadata: 4 | name: nginx-gateway 5 | spec: 6 | - gatewayClassName: nginx 7 | listeners: 8 | - name: http 9 | protocol: HTTP 10 | port: 80 11 | allowedRoutes: 12 | kind: 13 | - kind: HTTPRoute 14 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/gatewayapi/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: nginx-gateway-service 5 | spec: 6 | type: ClusterIP 7 | selector: 8 | app: nginx-app 9 | ports: 10 | - protocol: TCP 11 | port: 80 # Port the service is listening on 12 | targetPort: 80 # Port the container is listening on (if unset, defaults to equal port value) 13 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/ingress/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: nginx-ingress-deployment 5 | spec: 6 | replicas: 3 7 | selector: 8 | matchLabels: 9 | app: nginx-app 10 | template: 11 | metadata: 12 | labels: 13 | app: nginx-app 14 | spec: 15 | containers: 16 | - name: nginx 17 | image: nginx:1.26.0 -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/ingress/ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1 2 | kind: Ingress 3 | metadata: 4 | name: nginx-ingress-ingress 5 | spec: 6 | ingressClassName: nginx 7 | rules: 8 | - host: e1218320-b90e-4c0a-be3f-0ddf63f1b87f.lb.civo.com 9 | http: 10 | paths: 11 | - path: / 12 | pathType: Prefix 13 | backend: 14 | service: 15 | name: nginx-ingress-service 16 | port: 17 | number: 80 18 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/ingress/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: nginx-ingress-service 5 | spec: 6 | type: ClusterIP 7 | selector: 8 | app: nginx-app 9 | ports: 10 | - protocol: TCP 11 | port: 80 # Port the service is listening on 12 | targetPort: 80 # Port the container is listening on (if unset, defaults to equal port value) 13 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/job/job-better.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: batch/v1 2 | kind: Job 3 | metadata: 4 | name: echo-date-better 5 | spec: 6 | parallelism: 2 # This is the number of pods that will run in parallel 7 | completions: 2 # This is the number of pods that need to complete successfully 8 | activeDeadlineSeconds: 100 # This is the maximum time the job can run 9 | backoffLimit: 1 10 | template: 11 | metadata: 12 | labels: 13 | app: echo-date 14 | spec: 15 | containers: 16 | - name: echo 17 | image: cgr.dev/chainguard/busybox:latest 18 | command: [date] 19 | resources: 20 | requests: 21 | memory: "64Mi" 22 | cpu: "250m" 23 | limits: 24 | memory: "64Mi" 25 | cpu: "250m" 26 | securityContext: 27 | allowPrivilegeEscalation: false 28 | privileged: false 29 | runAsUser: 1001 30 | runAsGroup: 1001 31 | runAsNonRoot: true 32 | restartPolicy: Never 33 | securityContext: 34 | seccompProfile: 35 | type: RuntimeDefault 36 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/job/job.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: batch/v1 2 | kind: Job 3 | metadata: 4 | name: echo-date 5 | spec: 6 | template: 7 | spec: 8 | containers: 9 | - name: echo 10 | image: busybox:1.36.1 11 | command: [date] 12 | restartPolicy: Never 13 | backoffLimit: 1 -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/namespace/Namespace.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: my-namespace -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/persistentvolume/civo/satefulset-pvc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: StatefulSet 3 | metadata: 4 | name: individual-pvc 5 | spec: 6 | serviceName: nginxs 7 | replicas: 2 8 | selector: 9 | matchLabels: 10 | app: nginx-app 11 | template: 12 | metadata: 13 | labels: 14 | app: nginx-app 15 | spec: 16 | containers: 17 | - name: nginx 18 | image: nginx:1.26.0 19 | ports: 20 | - containerPort: 80 21 | volumeMounts: 22 | - name: data 23 | mountPath: "/usr/share/nginx/html" 24 | volumeClaimTemplates: 25 | - metadata: 26 | name: data 27 | spec: 28 | accessModes: [ "ReadWriteOnce" ] 29 | resources: 30 | requests: 31 | storage: 1Gi 32 | storageClassName: civo-volume 33 | --- 34 | apiVersion: v1 35 | kind: Service 36 | metadata: 37 | name: nginxs 38 | spec: 39 | clusterIP: None 40 | selector: 41 | app: nginx-app 42 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/persistentvolume/civo/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: nginx-service 5 | spec: 6 | selector: 7 | app: nginx-app 8 | ports: 9 | - protocol: TCP 10 | port: 80 11 | targetPort: 80 12 | type: LoadBalancer -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/persistentvolume/kind/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: shared-pvc-kind 5 | spec: 6 | replicas: 2 7 | selector: 8 | matchLabels: 9 | app: nginx-app 10 | template: 11 | metadata: 12 | labels: 13 | app: nginx-app 14 | spec: 15 | containers: 16 | - name: nginx 17 | image: nginx:1.26.0 18 | ports: 19 | - containerPort: 80 20 | volumeMounts: 21 | - name: shared-pvc 22 | mountPath: /usr/share/nginx/html 23 | volumes: 24 | - name: shared-pvc 25 | persistentVolumeClaim: 26 | claimName: dynamic-pvc-kind 27 | --- 28 | apiVersion: v1 29 | kind: PersistentVolumeClaim 30 | metadata: 31 | name: dynamic-pvc-kind 32 | spec: 33 | accessModes: 34 | - ReadWriteOnce 35 | resources: 36 | requests: 37 | storage: 100Mi 38 | storageClassName: standard 39 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/persistentvolume/kind/dynamic/stateful-pvc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: StatefulSet 3 | metadata: 4 | name: individual-pvc 5 | spec: 6 | serviceName: nginxs 7 | replicas: 2 8 | selector: 9 | matchLabels: 10 | app: nginx-app 11 | template: 12 | metadata: 13 | labels: 14 | app: nginx-app 15 | spec: 16 | containers: 17 | - name: nginx 18 | image: nginx:1.26.0 19 | ports: 20 | - containerPort: 80 21 | volumeMounts: 22 | - name: data 23 | mountPath: "/usr/share/nginx/html" 24 | volumeClaimTemplates: 25 | - metadata: 26 | name: data 27 | spec: 28 | accessModes: [ "ReadWriteOnce" ] 29 | storageClassName: standard 30 | resources: 31 | requests: 32 | storage: 1Gi 33 | --- 34 | apiVersion: v1 35 | kind: Service 36 | metadata: 37 | name: nginxs 38 | spec: 39 | clusterIP: None 40 | selector: 41 | app: nginx-app 42 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/persistentvolume/kind/manual/persistentvolume.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolume 3 | metadata: 4 | name: manual-pv 5 | # labels: 6 | # type: local 7 | spec: 8 | storageClassName: standard 9 | capacity: 10 | storage: 500Mi 11 | accessModes: 12 | - ReadWriteOnce 13 | hostPath: 14 | path: "/mnt/data" -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/persistentvolume/kind/manual/persistentvolumeclaim.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolumeClaim 3 | metadata: 4 | name: manual-pvc 5 | spec: 6 | storageClassName: standard 7 | accessModes: 8 | - ReadWriteOnce 9 | resources: 10 | requests: 11 | storage: 100Mi -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/persistentvolume/kind/manual/pod.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: manual-pod 5 | spec: 6 | containers: 7 | - name: nginx 8 | image: nginx:1.26.0 9 | ports: 10 | - containerPort: 80 11 | name: "http-server" 12 | volumeMounts: 13 | - name: storage 14 | mountPath: "/usr/share/nginx/html" 15 | volumes: 16 | - name: storage 17 | persistentVolumeClaim: 18 | claimName: manual-pvc 19 | 20 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/pod/pod-best-practices.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: nginx-pod-best-practices 5 | namespace: my-namespace 6 | spec: 7 | containers: 8 | - name: nginx 9 | image: cgr.dev/chainguard/nginx:latest 10 | ports: 11 | - containerPort: 8080 12 | protocol: TCP 13 | readinessProbe: 14 | httpGet: 15 | path: / 16 | port: 8080 17 | resources: 18 | requests: 19 | memory: "50Mi" 20 | cpu: "250m" 21 | limits: 22 | memory: "50Mi" 23 | cpu: "250m" 24 | securityContext: # This is the security context for the container 25 | allowPrivilegeEscalation: false 26 | privileged: false 27 | securityContext: # This is the security context for the pod 28 | seccompProfile: 29 | type: RuntimeDefault 30 | runAsUser: 1000 31 | runAsGroup: 1001 32 | runAsNonRoot: true 33 | 34 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/pod/pod.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: ngix-pod 5 | namespace: my-namespace 6 | spec: 7 | containers: 8 | - name: nginx 9 | image: nginx:1.26.0 10 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/rbac/job-no-perms.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: batch/v1 2 | kind: Job 3 | metadata: 4 | name: job-no-perms 5 | spec: 6 | template: 7 | spec: 8 | containers: 9 | - name: kubectl 10 | image: cgr.dev/chainguard/kubectl 11 | args: ["get", "pods", "-A"] 12 | restartPolicy: Never 13 | backoffLimit: 1 -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/rbac/with-prems/cluster-role-binding-pod-reader.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRoleBinding 3 | metadata: 4 | name: pod-reader 5 | roleRef: 6 | apiGroup: rbac.authorization.k8s.io 7 | kind: ClusterRole 8 | name: pod-reader 9 | subjects: 10 | - kind: ServiceAccount 11 | name: cluster-pod-reader 12 | namespace: rbac -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/rbac/with-prems/cluster-role-pod-reader.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: ClusterRole 3 | metadata: 4 | name: pod-reader 5 | rules: 6 | - apiGroups: [""] # "" indicates the core API group 7 | resources: ["pods"] # Resource type 8 | verbs: ["get", "watch", "list"] # Actions -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/rbac/with-prems/job-pod-reader.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: batch/v1 2 | kind: Job 3 | metadata: 4 | name: job-no-perms 5 | spec: 6 | template: 7 | spec: 8 | automountServiceAccountToken: true 9 | containers: 10 | - name: kubectl 11 | image: cgr.dev/chainguard/kubectl 12 | args: ["get", "pods", "-A"] 13 | serviceAccountName: cluster-pod-reader 14 | restartPolicy: Never 15 | backoffLimit: 1 -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/rbac/with-prems/service-account-pod-reader.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: cluster-pod-reader -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/replicaset/replicaset.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: ReplicaSet 3 | metadata: 4 | name: nginx-minimal 5 | spec: 6 | replicas: 3 7 | selector: 8 | matchLabels: 9 | app: nginx-minimal # Matching the labels of the pod 10 | template: 11 | metadata: 12 | labels: 13 | app: nginx-minimal # Applying the labels to the pod 14 | spec: 15 | containers: 16 | - name: nginx 17 | image: nginx:1.26.0 18 | ports: 19 | - containerPort: 80 -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/secret/a.deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: secret-env-pod 5 | spec: 6 | containers: 7 | - name: secret-env-pod 8 | image: redis 9 | env: 10 | - name: SECRET_USERNAME 11 | valueFrom: 12 | secretKeyRef: 13 | name: newsecret 14 | key: username 15 | - name: SECRET_PASSWORD 16 | valueFrom: 17 | secretKeyRef: 18 | name: newsecret 19 | key: password 20 | restartPolicy: Never -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/secret/a.secret.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: base64-data 5 | type: Opaque # This is the default type 6 | data: 7 | username: YWRtaW4= 8 | password: MWYyZDFlMmU2N2Rm 9 | email: YWRtaW5AZXhhbXBsZS5jb20= 10 | 11 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/secret/secret-data.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: base64-data 5 | type: Opaque # This is the default type 6 | data: 7 | foo: bar 8 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/secret/secret-dockerconfigjson.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: dockerconfigjson 5 | type: kubernetes.io/dockerconfigjson 6 | data: 7 | .dockerconfigjson: | 8 | eyJhdXRocyI6eyJodHRwczovL2luZGV4LmRvY2tlci5pby92MSI6eyJ1c2VybmFtZSI6InVzZXJuYW1lIiwicGFzc3dvcmQiOiJwYXNzd29yZCIsImVtYWlsIjoiZm9vQGJhci5jb20iLCJhdXRoIjoiZFhObGNtNWhiV1U2Y0dGemMzZHZjbVE9In19fQ== 9 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/secret/secret-string.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: string-data 5 | type: Opaque # This is the default type 6 | stringData: 7 | foo: bar 8 | 9 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/service/Service-loadbalancer.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: nginx-loadbalancer 5 | spec: 6 | type: LoadBalancer # Will only work if cluster is configured to provision one from an external source (e.g. cloud provider) 7 | selector: 8 | baz: pod-label 9 | ports: 10 | - protocol: TCP 11 | port: 80 # Port the service is listening on 12 | targetPort: 80 # Port the container is listening on (if unset, defaults to equal port value) 13 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/service/Service-nodeport.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: nginx-nodeport 5 | spec: 6 | type: NodePort 7 | selector: 8 | baz: pod-label 9 | ports: 10 | - protocol: TCP 11 | port: 80 # Port the service is listening on 12 | targetPort: 80 # Port the container is listening on (if unset, defaults to equal port value) 13 | # nodePort: 30XXX (if unset, kubernetes will assign a port within 30000-32767) 14 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/service/deployment.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: nginx-minimal 5 | labels: 6 | foo: deployment-label 7 | annotations: 8 | bar: deployment-annotation 9 | spec: 10 | replicas: 3 11 | selector: 12 | matchLabels: 13 | baz: pod-label 14 | template: 15 | metadata: 16 | labels: 17 | baz: pod-label 18 | annotations: 19 | bing: pod-annotation 20 | spec: 21 | containers: 22 | - name: nginx 23 | image: nginx:1.26.0 -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/service/service-clusterip.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: nginx-clusterip 5 | labels: 6 | foo: service-label 7 | annotations: 8 | bar: service-annotation 9 | spec: 10 | type: ClusterIP # This is the default value 11 | selector: 12 | baz: pod-label 13 | ports: 14 | - protocol: TCP 15 | port: 80 # Port the service is listening on 16 | targetPort: 80 # Port the container is listening on (if unset, defaults to equal port value) 17 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/statefulset/service-nginx-headless.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: nginxs # Plural because it sets up DNS for each replica in the StatefulSet (e.g. nginx-0.nginxs.default.svc.cluster.local) 5 | spec: 6 | type: ClusterIP 7 | clusterIP: None # This makes it a "headless" service 8 | selector: 9 | app: nginx 10 | ports: 11 | - protocol: TCP 12 | port: 80 13 | targetPort: 80 14 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/statefulset/service-nginx.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: nginx # singular since it points to a single cluster IP 5 | spec: 6 | type: ClusterIP 7 | selector: 8 | app: nginx 9 | ports: 10 | - protocol: TCP 11 | port: 80 12 | targetPort: 80 13 | 14 | -------------------------------------------------------------------------------- /docs/kubernetes/k8s-resources-type/statefulset/stateful.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: StatefulSet 3 | metadata: 4 | name: nginx-with-init-containers 5 | spec: 6 | serviceName: nginxs # Headless service 7 | replicas: 3 8 | selector: 9 | matchLabels: 10 | app: nginx-app 11 | template: 12 | metadata: 13 | labels: 14 | app: nginx-app 15 | spec: 16 | initContainers: 17 | - name: populate-default-html 18 | image: nginx:1.26.0 19 | command: 20 | - bash 21 | - "-c" 22 | - | 23 | set -ex 24 | [[ $HOSTNAME =~ -([0-9]+)$ ]] || exit 1 25 | ordinal=${BASH_REMATCH[1]} 26 | echo "

Hello from pod $ordinal

" > /usr/share/nginx/html/index.html 27 | volumeMounts: 28 | - name: data 29 | mountPath: /usr/share/nginx/html 30 | containers: 31 | - name: nginx 32 | image: nginx:1.26.0 33 | volumeMounts: 34 | - name: data 35 | mountPath: /usr/share/nginx/html 36 | 37 | volumeClaimTemplates: # PersistentVolumeClaim templates for each replica 38 | - metadata: 39 | name: data 40 | spec: 41 | accessModes: ["ReadWriteOnce"] 42 | storageClassName: "standard" 43 | resources: 44 | requests: 45 | storage: 100Mi 46 | -------------------------------------------------------------------------------- /docs/kubernetes/learning-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | title: Learning Resources 4 | description: A collection of resources to learn more about Kubernetes. 5 | tags: ["Kubernetes", "Containerization", "DevOps"] 6 | keywords: ["Kubernetes", "Containerization", "DevOps"] 7 | slug: "/kubernetes/resources" 8 | --- 9 | 10 | - [Complete Kubernetes Course - From BEGINNER to PRO by DevOps Directive](https://youtu.be/2T86xAtR6Fo?si=vVtltmpU2aw2gqXy) 11 | - [Kubernetes 101 Kubesimplify](https://www.youtube.com/live/PN3VqbZqmD8?feature=share) 12 | - [Docker Mastery: with Kubernetes +Swarm from a Docker Captain](https://www.udemy.com/course/docker-mastery/) Udemy course. 13 | - [BretFisher/udemy-docker-mastery GitHub repo](https://github.com/BretFisher/udemy-docker-mastery) 14 | - [Kubernetes official docs](https://kubernetes.io/docs/home/) 15 | - [Kubernetes Basic Concepts - Blog](https://spacelift.io/blog/kubernetes-tutorial) 16 | -------------------------------------------------------------------------------- /docs/kubernetes/other-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 6 3 | title: Other Resources 4 | description: A collection of resources to learn more about Kubernetes. 5 | tags: ["Kubernetes", "Containerization", "DevOps"] 6 | keywords: ["Kubernetes", "Containerization", "DevOps"] 7 | slug: "/kubernetes/other-resources" 8 | --- 9 | 10 | Here are list of other resources that you can refer to learn more about Kubernetes: 11 | 12 | - [Kubernetes apps](https://github.com/Pradumnasaraf/DevOps/tree/main/docs/kubernetes/apps): A collection of simple Kubernetes applications that you can use to learn Kubernetes. 13 | -------------------------------------------------------------------------------- /docs/kubernetes/playground.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 5 3 | title: Playground 4 | description: A collection of Kubernetes playgrounds that you can use to learn and experiment with Kubernetes. 5 | tags: ["Kubernetes", "Containerization", "DevOps"] 6 | keywords: ["Kubernetes", "Containerization", "DevOps"] 7 | slug: "/kubernetes/playground" 8 | --- 9 | 10 | Kubernetes Playground is a web-based Kubernetes environment that allows you to learn and experiment with Kubernetes. It is a great way to get started with Kubernetes without having to install it on your local machine. 11 | 12 | - [labs.play-with-k8s.com](https://labs.play-with-k8s.com/) 13 | - [killercoda.com/playgrounds](https://killercoda.com/playgrounds) 14 | -------------------------------------------------------------------------------- /docs/kubernetes/tools/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Tools", 3 | "position": 4 4 | } 5 | -------------------------------------------------------------------------------- /docs/kubernetes/tools/k9s.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: K9s 3 | sidebar_position: 5 4 | description: K9s is a terminal-based UI to interact with your Kubernetes clusters. It provides a rich set of features to manage your Kubernetes resources. 5 | tags: [Kubernetes, Tools] 6 | keywords: [Kubernetes, Tools, K9s] 7 | slug: /kubernetes/tools/k9s 8 | --- 9 | 10 | K9s is a terminal-based UI to interact with your Kubernetes clusters. It provides a rich set of features to manage your Kubernetes resources. It can help you to navigate your Kubernetes clusters, view resource details, and perform actions on resources. Super useful for debugging and troubleshooting your Kubernetes applications. 11 | 12 | ## Resources 13 | 14 | - [K9s GitHub Repository](https://github.com/derailed/k9s) 15 | - [K9s Documentation](https://k9scli.io/) 16 | 17 | ## Installation 18 | 19 | You can install k9s on MacOS using Homebrew. 20 | 21 | ```bash 22 | brew install k9s 23 | ``` 24 | 25 | Once you have K9s installed, you can start it by running the following command 26 | 27 | ```bash 28 | k9s 29 | ``` 30 | It will show the show the resources running in your Kubernetes cluster (for the current context and namespace). 31 | 32 | ![K9s](https://github.com/user-attachments/assets/4d3fefc3-34eb-407d-bae2-3299dd72f88c) 33 | 34 | -------------------------------------------------------------------------------- /docs/kubernetes/tools/kubent.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Kubent 3 | sidebar_position: 6 4 | description: A simple tool to check whether you're using any of these API versions in your cluster and therefore should upgrade your workloads first, before upgrading your Kubernetes cluster. 5 | tags: [Kubernetes, Tools] 6 | keywords: [Kubernetes, Tools, Kubent] 7 | slug: /kubernetes/tools/kubent 8 | --- 9 | 10 | Kubent (Kube No Trouble) is a simple tool to check whether you're using any of these API versions in your cluster and therefore should upgrade your workloads first, before upgrading your Kubernetes cluster. 11 | 12 | ## Resources 13 | 14 | - [Kubent GitHub Repository](https://github.com/doitintl/kube-no-trouble) 15 | 16 | ## Installation 17 | 18 | You can install Kubent on MacOS using Homebrew. 19 | 20 | ```bash 21 | brew install kubent 22 | ``` -------------------------------------------------------------------------------- /docs/kubernetes/tools/kubescape.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Kubescape 3 | sidebar_position: 2 4 | description: A tool that helps you scan your Kubernetes clusters for security misconfigurations. 5 | tags: [Kubernetes, Tools, Security] 6 | keywords: [Kubernetes, Tools, Security, Kubescape] 7 | slug: /kubernetes/tools/kubescape 8 | --- 9 | 10 | 11 | Kubescape is a tool that helps you scan your Kubernetes clusters for security misconfigurations. We can scan local cluster and config files. 12 | 13 | - [Website](https://armosec.io/kubescape) 14 | - [Docs](https://hub.armosec.io/docs) 15 | - [GitHub](https://github.com/kubescape/kubescape) 16 | 17 | ### Usage 18 | 19 | For more usages head over to [GitHub](https://github.com/kubescape/kubescape) 20 | 21 | - Install Kubescape 22 | 23 | Installations instructions can be found [here](https://github.com/kubescape/kubescape#install-on-macos) 24 | 25 | - To scan local YAML/JSON files. 26 | 27 | ```bash 28 | kubescape scan *.yaml 29 | ``` 30 | 31 | - To Scan Kubernetes manifest files from a git repository 32 | 33 | ```bash 34 | kubescape scan https://github.com/kubescape/kubescape 35 | ``` 36 | 37 | - We can output the results in JSON, html, and markdown PDF. 38 | 39 | ```bash 40 | kubescape scan *.yaml --output results.json 41 | kubescape scan *.yaml --output results.pdf 42 | kubescape scan *.yaml --output results.html 43 | ``` -------------------------------------------------------------------------------- /docs/kubernetes/tools/kustomize/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Kustomize", 3 | "position": 7 4 | } 5 | -------------------------------------------------------------------------------- /docs/kubernetes/tools/kustomize/app/base/ConfigMap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: nginx-configmap 5 | namespace: nginx-demo 6 | data: 7 | index.html: | 8 |

Hello World from ConfigMap

9 | -------------------------------------------------------------------------------- /docs/kubernetes/tools/kustomize/app/base/Deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: nginx-deployment 5 | namespace: nginx-demo 6 | spec: 7 | selector: 8 | matchLabels: 9 | app: nginx-app 10 | template: 11 | metadata: 12 | labels: 13 | app: nginx-app 14 | spec: 15 | containers: 16 | - name: nginx 17 | image: nginx:latest 18 | ports: 19 | - containerPort: 80 20 | resources: 21 | limits: 22 | cpu: 100m 23 | memory: 100Mi 24 | requests: 25 | cpu: 100m 26 | memory: 100Mi 27 | readinessProbe: 28 | failureThreshold: 3 29 | httpGet: 30 | path: / 31 | port: 80 32 | volumeMounts: 33 | - name: html-file 34 | mountPath: /usr/share/nginx/html 35 | 36 | volumes: 37 | - name: html-file 38 | configMap: 39 | name: nginx-configmap 40 | 41 | 42 | -------------------------------------------------------------------------------- /docs/kubernetes/tools/kustomize/app/base/Kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | namespace: nginx-demo 4 | resources: 5 | - Deployment.yaml 6 | - Service.yaml 7 | - ConfigMap.yaml 8 | -------------------------------------------------------------------------------- /docs/kubernetes/tools/kustomize/app/base/Service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: nginx-service-clusterip 5 | namespace: nginx-demo 6 | spec: 7 | selector: 8 | app: nginx-app 9 | ports: 10 | - port: 80 11 | targetPort: 80 12 | -------------------------------------------------------------------------------- /docs/kubernetes/tools/kustomize/app/development/Kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | namespace: nginx-demo 4 | resources: 5 | - ../base 6 | patches: 7 | - path: ./patches/Deployment.yaml 8 | - path: ./patches/ConfigMap.yaml 9 | -------------------------------------------------------------------------------- /docs/kubernetes/tools/kustomize/app/development/patches/ConfigMap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: nginx-configmap 5 | namespace: nginx-demo 6 | data: 7 | index.html: | 8 |

Hello World from Development

9 | -------------------------------------------------------------------------------- /docs/kubernetes/tools/kustomize/app/development/patches/Deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: nginx-deployment 5 | namespace: nginx-demo 6 | spec: 7 | replicas: 2 8 | template: 9 | spec: 10 | containers: 11 | - name: nginx 12 | image: nginx:1.26.0 13 | -------------------------------------------------------------------------------- /docs/kubernetes/tools/kustomize/app/production/Kustomization.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | namespace: nginx-demo 4 | resources: 5 | - ../base 6 | patches: 7 | - path: ./patches/Deployment.yaml 8 | - path: ./patches/ConfigMap.yaml 9 | -------------------------------------------------------------------------------- /docs/kubernetes/tools/kustomize/app/production/patches/ConfigMap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: nginx-configmap 5 | namespace: nginx-demo 6 | data: 7 | index.html: | 8 |

Hello World from Production

9 | -------------------------------------------------------------------------------- /docs/kubernetes/tools/kustomize/app/production/patches/Deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: nginx-deployment 5 | namespace: nginx-demo 6 | spec: 7 | replicas: 3 8 | template: 9 | spec: 10 | containers: 11 | - name: nginx 12 | image: nginx:1.27.0 13 | -------------------------------------------------------------------------------- /docs/kubernetes/tools/kustomize/introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Kustomize Introduction 3 | sidebar_position: 1 4 | description: A collection of resources to learn more about Kustomize. 5 | tags: ["Kustomize", "Kubernetes", "DevOps"] 6 | keywords: ["Kustomize", "Kubernetes", "DevOps"] 7 | slug: "/kubernetes/tools/kustomize" 8 | --- 9 | 10 | Kustomize is a tool that lets you customize raw, template-free YAML files for multiple purposes, leaving the original YAML untouched and usable as is. 11 | 12 | Kustomize uses the `apiVersion`, `kind`, `name` and `namespace` to identify resources. It appends a suffix to the name and namespace fields to differentiate between different versions of the same resource. 13 | 14 | ## Resources 15 | 16 | -------------------------------------------------------------------------------- /docs/kubernetes/tools/lens.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Lens IDE 3 | sidebar_position: 1 4 | description: Lens IDE is the Kubernetes IDE that makes working with Kubernetes easier. 5 | tags: [Kubernetes, Lens, IDE] 6 | keywords: [Kubernetes, Lens, IDE] 7 | slug: /kubernetes/tools/lens 8 | --- 9 | 10 | It can be used to manage multiple Kubernetes cluster. 11 | 12 | ### Installation 13 | 14 | - Download the Lens from [here](https://k8slens.dev/). 15 | 16 | Screenshot 2022-12-17 at 7 20 59 PM 17 | -------------------------------------------------------------------------------- /docs/kubernetes/tools/validkube.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: ValidKube 3 | sidebar_position: 4 4 | 5 | --- 6 | 7 | ## ValidKube 8 | 9 | - Website - [validkube.com](https://validkube.com/) 10 | 11 | - It is a tool to validate the Kubernetes YAML files to find vulnerabilities, security issues, and best practices. 12 | 13 | Screenshot 2022-12-17 at 7 18 25 PM 14 | 15 | -------------------------------------------------------------------------------- /docs/linux/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Linux", 3 | "position": 5 4 | } 5 | -------------------------------------------------------------------------------- /docs/linux/learning-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | title: Learning Resources 4 | description: A collection of resources to learn more about Linux. 5 | tags: ["Linux", "Operating System", "Kernel"] 6 | keywords: ["Linux", "Operating System", "Kernel"] 7 | slug: "/linux/resources" 8 | --- 9 | 10 | - [Linux kernel source tree](https://github.com/torvalds/linux) 11 | - [Linux & Docker Fundamentals - Kubesimplify](https://www.youtube.com/live/EUu1E_YKGTw?feature=share) -------------------------------------------------------------------------------- /docs/networking/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Networking", 3 | "position": 7 4 | } 5 | -------------------------------------------------------------------------------- /docs/networking/learning-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | title: Learning Resources 4 | description: A collection of resources to learn more about Computer Networking. 5 | tags: ["Computer Networking", "Networking", "Network"] 6 | keywords: ["Computer Networking", "Networking", "Network"] 7 | slug: "/networking/resources" 8 | --- 9 | 10 | - [Computer Networking](https://youtu.be/IPvYjXCsTg8) -------------------------------------------------------------------------------- /docs/prometheus/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Prometheus", 3 | "position": 10 4 | } 5 | -------------------------------------------------------------------------------- /docs/prometheus/introduction.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | title: Prometheus Introduction 4 | description: A collection of resources to learn more about Prometheus. 5 | tags: ["Prometheus", "Monitoring", "Alerting", "Kubernetes"] 6 | keywords: ["Prometheus", "Monitoring", "Alerting", "Kubernetes"] 7 | slug: "/prometheus" 8 | --- 9 | 10 | Prometheus is an open-source systems monitoring and alerting toolkit. 11 | 12 | ### Installation using Helm 13 | 14 | We will install Prometheus Operator using Helm. It is collection of Promethus + Grafana + Alertmanager + Node Exporter + Kube State Metrics + Pushgateway + Blackbox Exporter 15 | 16 | 17 | Step 1: Create a Kubernetes Namespace 18 | 19 | ```bash 20 | kubectl create namespace monitoring 21 | ``` 22 | Step 2: Install Prometheus Operator 23 | 24 | ```bash 25 | helm repo add prometheus-community https://prometheus-community.github.io/helm-charts 26 | helm repo update 27 | helm install prometheus prometheus-community/kube-prometheus-stack -n monitoring 28 | ``` 29 | Step 3: Accessing though localhost by Port forwarding 30 | 31 | ```bash 32 | kubectl port-forward svc/prometheus-grafana 3000:80 -n monitoring 33 | ``` 34 | 35 | > The Grafana dashboard will be available at http://localhost:3000. The default username and password are `admin` $ `prom-operator`. 36 | 37 | 38 | ### What's next? 39 | 40 | - [Learning Resources](./learning-resources.md) - Learn more about Prometheus with these resources. -------------------------------------------------------------------------------- /docs/prometheus/learning-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | title: Learning Resources 4 | description: A collection of resources to learn more about Prometheus. 5 | tags: ["Prometheus", "Monitoring", "Alerting", "Time Series Database"] 6 | keywords: ["Prometheus", "Monitoring", "Alerting", "Time Series Database"] 7 | slug: "/prometheus/resources" 8 | --- 9 | 10 | - [Prometheus Playlist - TechWorld with Nana](https://youtube.com/playlist?list=PLy7NrYWoggjxCF3av5JKwyG7FFF9eLeL4) -------------------------------------------------------------------------------- /docs/terraform/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Terraform", 3 | "position": 18 4 | } 5 | -------------------------------------------------------------------------------- /docs/terraform/files/Terraform-KodeKloud.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pradumnasaraf/DevOps/ca22bd71c59ef36a3732be90e67e4869bd6388de/docs/terraform/files/Terraform-KodeKloud.pdf -------------------------------------------------------------------------------- /docs/terraform/files/aws/aws-provider.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = "us-east" 3 | profile = "default" 4 | } -------------------------------------------------------------------------------- /docs/terraform/files/aws/backend-s3.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | backend "s3" { 3 | bucket = "remote-state" 4 | key = "terraform.tfstate" 5 | region = "us-east-1" 6 | } 7 | } -------------------------------------------------------------------------------- /docs/terraform/files/aws/iam-user-policy.tf: -------------------------------------------------------------------------------- 1 | # main.tf 2 | resource "aws_iam_user" "admin-user" { 3 | name = "lucy" 4 | tags = { 5 | Description = "Technical Team Leader" 6 | } 7 | } 8 | 9 | resource "aws_iam_policy" "adminUser" { 10 | name = "AdminUsers" 11 | policy = < 2 | 3 | 4 | 26 |

27 | 28 | -------------------------------------------------------------------------------- /docs/webassembly/files/apps/hello-wat/hello-wasm.wasm: -------------------------------------------------------------------------------- 1 | asm``consolelogmemorymain 2 | A A Hello, WebAssembly! -------------------------------------------------------------------------------- /docs/webassembly/files/apps/hello-wat/hello-wasm.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (import "console" "log" (func $log (param i32))) 3 | (memory 1) 4 | (export "memory" (memory 0)) 5 | (data (i32.const 0) "Hello, WebAssembly!") 6 | (func $main 7 | i32.const 0 8 | call $log) 9 | (export "main" (func $main)) 10 | ) -------------------------------------------------------------------------------- /docs/webassembly/files/apps/hello-world/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | printf("Hello, WebAssembly!\n"); 5 | return 0; 6 | } -------------------------------------------------------------------------------- /docs/webassembly/files/apps/hello-world/hello.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pradumnasaraf/DevOps/ca22bd71c59ef36a3732be90e67e4869bd6388de/docs/webassembly/files/apps/hello-world/hello.wasm -------------------------------------------------------------------------------- /docs/webassembly/files/apps/kodekloud/Section 1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pradumnasaraf/DevOps/ca22bd71c59ef36a3732be90e67e4869bd6388de/docs/webassembly/files/apps/kodekloud/Section 1.pdf -------------------------------------------------------------------------------- /docs/webassembly/files/apps/kodekloud/Section 2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pradumnasaraf/DevOps/ca22bd71c59ef36a3732be90e67e4869bd6388de/docs/webassembly/files/apps/kodekloud/Section 2.pdf -------------------------------------------------------------------------------- /docs/webassembly/files/apps/kodekloud/Section 3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pradumnasaraf/DevOps/ca22bd71c59ef36a3732be90e67e4869bd6388de/docs/webassembly/files/apps/kodekloud/Section 3.pdf -------------------------------------------------------------------------------- /docs/webassembly/files/apps/kodekloud/Section 4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pradumnasaraf/DevOps/ca22bd71c59ef36a3732be90e67e4869bd6388de/docs/webassembly/files/apps/kodekloud/Section 4.pdf -------------------------------------------------------------------------------- /docs/webassembly/files/apps/kodekloud/Section 6.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pradumnasaraf/DevOps/ca22bd71c59ef36a3732be90e67e4869bd6388de/docs/webassembly/files/apps/kodekloud/Section 6.pdf -------------------------------------------------------------------------------- /docs/webassembly/learning-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | title: Learning Resources 4 | description: A collection of resources to learn more about WebAssembly. 5 | tags: ["WebAssembly", "Assembly", "Web Development"] 6 | keywords: ["WebAssembly", "Assembly", "Web Development"] 7 | slug: "/webassembly/resources" 8 | --- 9 | 10 | - [WebAssembly](https://webassembly.org/) - The official WebAssembly website. 11 | - [MDN Web Docs](https://developer.mozilla.org/en-US/docs/WebAssembly) - Mozilla Developer Network's WebAssembly documentation. 12 | - [GitHub WebAssembly](https://github.com/WebAssembly) - WebAssembly's GitHub organization. 13 | - [Awesome Wasm repo](https://github.com/mbasso/awesome-wasm) - A curated list of awesome WebAssembly projects. 14 | - [KodeKloud WebAssembly Course](https://kodekloud.com/p/webassembly) - NOTE: This is a paid course. Mentioning it here as I used it to learn WebAssembly. -------------------------------------------------------------------------------- /docs/webassembly/tools.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | title: Tools 4 | description: A collection of tools for learn and experiment with WebAssembly. 5 | tags: ["WebAssembly", "Assembly", "Web Development"] 6 | keywords: ["WebAssembly", "Assembly", "Web Development"] 7 | slug: "/webassembly/tools" 8 | --- 9 | 10 | - [WasmFiddle](https://wasdk.github.io/WasmFiddle/) - An online playground for WebAssembly. 11 | - [WebAssembly Explorer](https://mbebenita.github.io/WasmExplorer/) - An online tool for exploring WebAssembly. 12 | - [WABT Online](https://webassembly.github.io/wabt/demo/wat2wasm/) - An online tool for working with WebAssembly. 13 | - [WasmCloud Playground](https://playground.wasmcloud.dev/) - An online tool for building and running WebAssembly modules. -------------------------------------------------------------------------------- /docs/yaml/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "YAML", 3 | "position": 8 4 | } -------------------------------------------------------------------------------- /docs/yaml/learning-resources.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | title: Learning Resources 4 | description: A collection of resources to learn more about YAML. 5 | tags: ["YAML", "Data Serialization", "Configuration"] 6 | keywords: ["YAML", "Data Serialization", "Configuration"] 7 | slug: "/yaml/resources" 8 | --- 9 | 10 | ## Learning Resources 11 | 12 | - [YAML Official Website](https://yaml.org/) 13 | - [Yaml Tutorial - TechWorld with Nana](https://youtu.be/1uFVr15xDGg) 14 | - [Complete YAML Course](https://youtu.be/IA90BTozdow) 15 | - [YAML: The Missing Battery in Python](https://realpython.com/python-yaml/) -------------------------------------------------------------------------------- /docs/yaml/tools.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 3 3 | title: Tools 4 | description: A collection of tools that can help you work with YAML files. 5 | tags: ["YAML", "DevOps", "Kubernetes"] 6 | keywords: ["YAML", "DevOps", "Kubernetes"] 7 | slug: "/yaml/tools" 8 | --- 9 | 10 | Here are some of the tools that you can use to work with YAML files: 11 | 12 | - [Yamllint](http://www.yamllint.com/) - Check the the format of the file. 13 | - [YAML Validator](https://codebeautify.org/yaml-validator) - Check the the format of the file. 14 | - [YAML to JSON](https://codebeautify.org/yaml-to-json-xml-csv) - Convert YAML to JSON. 15 | - [YAMLine](https://yamline.com/) - Collection of YAML tools: Formatter, Validator, Comparator, and Converter. 16 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "devops", 3 | "version": "2.6.1", 4 | "scripts": { 5 | "docusaurus": "docusaurus", 6 | "start": "docusaurus start", 7 | "build": "docusaurus build", 8 | "swizzle": "docusaurus swizzle", 9 | "deploy": "docusaurus deploy", 10 | "clear": "docusaurus clear", 11 | "serve": "docusaurus serve", 12 | "write-translations": "docusaurus write-translations", 13 | "write-heading-ids": "docusaurus write-heading-ids" 14 | }, 15 | "dependencies": { 16 | "@docusaurus/core": "^3.6.3", 17 | "@docusaurus/plugin-client-redirects": "^3.6.3", 18 | "@docusaurus/preset-classic": "^3.6.3", 19 | "@mdx-js/react": "^3.1.0", 20 | "clsx": "^2.1.1", 21 | "glob": "^11.0.0", 22 | "prism-react-renderer": "^2.4.0", 23 | "react": "^18.3.1", 24 | "react-dom": "^18.3.1", 25 | "rimraf": "^6.0.1" 26 | }, 27 | "devDependencies": { 28 | "@docusaurus/module-type-aliases": "^3.6.3", 29 | "@docusaurus/types": "^3.6.3" 30 | }, 31 | "browserslist": { 32 | "production": [ 33 | ">0.5%", 34 | "not dead", 35 | "not op_mini all" 36 | ], 37 | "development": [ 38 | "last 3 chrome version", 39 | "last 3 firefox version", 40 | "last 5 safari version" 41 | ] 42 | }, 43 | "engines": { 44 | "node": ">=22.0" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /sidebars.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creating a sidebar enables you to: 3 | - create an ordered group of docs 4 | - render a sidebar for each doc of that group 5 | - provide next/previous navigation 6 | 7 | The sidebars can be generated from the filesystem, or explicitly defined here. 8 | 9 | Create as many sidebars as you want. 10 | */ 11 | 12 | // @ts-check 13 | 14 | /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ 15 | const sidebars = { 16 | // By default, Docusaurus generates a sidebar from the docs folder structure 17 | tutorialSidebar: [{type: 'autogenerated', dirName: '.'}], 18 | 19 | // But you can create a sidebar manually 20 | /* 21 | tutorialSidebar: [ 22 | 'intro', 23 | 'hello', 24 | { 25 | type: 'category', 26 | label: 'Tutorial', 27 | items: ['tutorial-basics/create-a-document'], 28 | }, 29 | ], 30 | */ 31 | }; 32 | 33 | export default sidebars; 34 | -------------------------------------------------------------------------------- /src/components/HomepageFeatures/styles.module.css: -------------------------------------------------------------------------------- 1 | .features { 2 | display: flex; 3 | align-items: center; 4 | padding: 2rem 0; 5 | width: 100%; 6 | } 7 | 8 | .featureSvg { 9 | height: 200px; 10 | width: 200px; 11 | } 12 | -------------------------------------------------------------------------------- /src/css/custom.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Any CSS included here will be global. The classic template 3 | * bundles Infima by default. Infima is a CSS framework designed to 4 | * work well for content-centric websites. 5 | */ 6 | 7 | /* You can override the default Infima variables here. */ 8 | :root { 9 | --ifm-color-primary: #2e8555; 10 | --ifm-color-primary-dark: #29784c; 11 | --ifm-color-primary-darker: #277148; 12 | --ifm-color-primary-darkest: #205d3b; 13 | --ifm-color-primary-light: #33925d; 14 | --ifm-color-primary-lighter: #359962; 15 | --ifm-color-primary-lightest: #3cad6e; 16 | --ifm-code-font-size: 95%; 17 | --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1); 18 | } 19 | 20 | /* For readability concerns, you should choose a lighter palette in dark mode. */ 21 | [data-theme='dark'] { 22 | --ifm-color-primary: #25c2a0; 23 | --ifm-color-primary-dark: #21af90; 24 | --ifm-color-primary-darker: #1fa588; 25 | --ifm-color-primary-darkest: #1a8870; 26 | --ifm-color-primary-light: #29d5b0; 27 | --ifm-color-primary-lighter: #32d8b4; 28 | --ifm-color-primary-lightest: #4fddbf; 29 | --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3); 30 | } 31 | -------------------------------------------------------------------------------- /static/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pradumnasaraf/DevOps/ca22bd71c59ef36a3732be90e67e4869bd6388de/static/.nojekyll -------------------------------------------------------------------------------- /static/doc/k8s-troubleshooting.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pradumnasaraf/DevOps/ca22bd71c59ef36a3732be90e67e4869bd6388de/static/doc/k8s-troubleshooting.jpg -------------------------------------------------------------------------------- /static/img/devops-lifecycle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pradumnasaraf/DevOps/ca22bd71c59ef36a3732be90e67e4869bd6388de/static/img/devops-lifecycle.png -------------------------------------------------------------------------------- /static/img/devops-repo-card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pradumnasaraf/DevOps/ca22bd71c59ef36a3732be90e67e4869bd6388de/static/img/devops-repo-card.png -------------------------------------------------------------------------------- /static/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pradumnasaraf/DevOps/ca22bd71c59ef36a3732be90e67e4869bd6388de/static/img/favicon.ico --------------------------------------------------------------------------------