Coder Social home page Coder Social logo

Comments (2)

anishbista60 avatar anishbista60 commented on August 14, 2024

Postgress deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: workshop
  name: postgresql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgresql
  template:
    metadata:
      labels:
        app: postgresql
    spec:
      containers:
      - name: postgresql
        image: postgres:latest
        ports:
        - containerPort: 5432
        resources:
          requests:
            memory: "512Mi"
            cpu: "250m"
          limits:
            memory: "1Gi"
            cpu: "500m"
        env:
          - name: POSTGRES_DB
            value: mydatabase
          - name: POSTGRES_USER
            valueFrom:
              secretKeyRef:
                name: postgres-sec
                key: username
          - name: POSTGRES_PASSWORD
            valueFrom:
              secretKeyRef:
                name: postgres-sec
                key: password

postgressService.yaml

apiVersion: v1
kind: Service
metadata:
  namespace: workshop
  name: postgresql-svc
spec:
  selector:
    app: postgresql
  ports:
  - name: postgresql-svc
    protocol: TCP
    port: 5432
    targetPort: 5432


secret.yaml

apiVersion: v1
kind: Secret
metadata:
  namespace: workshop
  name: postgres-sec
type: Opaque
data:
  password: cGFzc3dvcmQxMjM= # password123 base64 encoded
  username: YWRtaW4=         # admin base64 encoded

Now also change the backendDeployment.yaml so that you can connect to postgress

apiVersion: apps/v1
kind: Deployment
metadata:
  name: api
  namespace: workshop
  labels:
    role: api
    env: demo
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 25%
  selector:
    matchLabels:
      role: api
  template:
    metadata:
      labels:
        role: api
    spec:
      containers:
      - name: api
        image: public.ecr.aws/w8u5e4v2/workshop-backend:v1
        imagePullPolicy: Always
        env:
          - name: DATABASE_URL
            value: postgres://<username>:<password>@postgresql-svc:5432/mydatabase
          - name: DATABASE_USERNAME
            valueFrom:
              secretKeyRef:
                name: postgres-sec
                key: username
          - name: DATABASE_PASSWORD
            valueFrom:
              secretKeyRef:
                name: postgres-sec
                key: password
        ports:
        - containerPort: 8080
        livenessProbe:
          httpGet:
            path: /ok
            port: 8080
          initialDelaySeconds: 2
          periodSeconds: 5
        readinessProbe:
          httpGet:
             path: /ok
             port: 8080
          initialDelaySeconds: 5
          periodSeconds: 5
          successThreshold: 1

from twsthreetierappchallenge.

Adesoji1 avatar Adesoji1 commented on August 14, 2024

from twsthreetierappchallenge.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.