Skip to content

Latest commit

 

History

History
106 lines (97 loc) · 2.86 KB

deployment-openshift.md

File metadata and controls

106 lines (97 loc) · 2.86 KB

Golang Deployment - Deployment with OpenShift Pipeline

Kubernetes Deployment for Simple Golang API

goreport all contributors tags docker pulls download all view clone issues pull requests forks stars license


Example CI/CD Script cicd-openshift.yml

apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
  name: bookstore-build
  labels:
    app: bookstore
spec:
  source:
    git:
      uri: https://github.com/devopscorner/golang-deployment.git
    contextDir: app
  strategy:
    dockerStrategy:
      dockerfilePath: Dockerfile
    type: Docker
  output:
    to:
      kind: ImageStreamTag
      name: devopscorner/bookstore:${IS_TAG}
  triggers:
    - type: ConfigChange
    - type: GitHub
      github:
        secret: my-secret
    - type: Generic
      generic:
        secret: my-secret
    - type: ImageChange
      imageChange:
        from:
          kind: ImageStreamTag
          name: devopscorner/bookstore:latest
  resources:
    limits:
      cpu: 1
      memory: 1Gi
    requests:
      cpu: 500m
      memory: 500Mi

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: bookstore-deployment
  labels:
    app: bookstore
spec:
  replicas: 1
  selector:
    matchLabels:
      app: bookstore
  template:
    metadata:
      labels:
        app: bookstore
    spec:
      containers:
        - name: bookstore
          image: devopscorner/bookstore:${IS_TAG}
          imagePullPolicy: Always
          ports:
            - containerPort: 8080
      imagePullSecrets:
        - name: my-registry-credentials

---

apiVersion: v1
kind: Service
metadata:
  name: bookstore-service
  labels:
    app: bookstore
spec:
  ports:
    - name: http
      port: 80
      targetPort: 8080
  selector:
    app: bookstore
  type: ClusterIP