Databases 11 min read

How to Deploy and Use Bytebase for Database CI/CD on Kubernetes

This guide explains why traditional DBA tasks are tedious, introduces Bytebase as a reliable database CI/CD platform, and provides step‑by‑step instructions for deploying Bytebase and PostgreSQL on Kubernetes, configuring GitLab integration, managing users, instances, projects, environments, and performing schema changes and data operations.

Ops Development Stories
Ops Development Stories
Ops Development Stories
How to Deploy and Use Bytebase for Database CI/CD on Kubernetes

What is Bytebase

Bytebase is positioned as a reliable database CI/CD platform that bridges developers and DBAs. Its core capabilities include:

SQL review

SQL auto‑correction

SQL editor

GitOps integration

Backup and restore

Multi‑tenant management

Installation & Deployment

Below is a quick walkthrough of deploying PostgreSQL and Bytebase on a Kubernetes cluster.

1. Deploy PostgreSQL

<code>---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: postgres-pv-claim
  labels:
    app: postgres
spec:
  storageClassName: longhorn
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
  labels:
    app: postgres
spec:
  selector:
    matchLabels:
      app: postgres
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
      - name: postgres
        image: postgres:15.2
        imagePullPolicy: IfNotPresent
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
          limits:
            cpu: 4
            memory: 8000Mi
        env:
        - name: POSTGRES_PASSWORD
          value: '123456'
        - name: POSTGRES_USER
          value: 'bytebase'
        - name: POSTGRES_DB
          value: 'postgres'
        - name: PGDATA
          value: /var/lib/postgresql/data/pgdata
        ports:
        - containerPort: 5432
          name: postgresport
        volumeMounts:
        - name: localtime
          mountPath: /etc/localtime
        - name: data-disk
          mountPath: /var/lib/postgresql/data
      volumes:
      - name: localtime
        hostPath:
          path: /usr/share/zoneinfo/Asia/Shanghai
      - name: data-disk
        persistentVolumeClaim:
          claimName: postgres-pv-claim
---
apiVersion: v1
kind: Service
metadata:
  name: postgres
spec:
  selector:
    app: postgres
  type: NodePort
  ports:
  - name: postgres
    port: 5432
    protocol: TCP
</code>

2. Deploy Bytebase

<code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: bytebase-pvc
  labels:
    app: bytebase
spec:
  storageClassName: longhorn
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 50Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: bytebase
spec:
  selector:
    matchLabels:
      app: bytebase
  template:
    metadata:
      labels:
        app: bytebase
    spec:
      containers:
      - name: bytebase
        image: bytebase/bytebase:1.13.0
        imagePullPolicy: IfNotPresent
        env:
        - name: PG_URL
          value: "postgresql://bytebase:123456@postgres:5432/postgres"
        args:
        - "--data"
        - "/var/opt/bytebase"
        - "--external-url"
        - "http://bytebase.jokerbai.com"
        - "--port"
        - "8080"
        ports:
        - containerPort: 8080
        volumeMounts:
        - name: data
          mountPath: /var/opt/bytebase
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8080
          initialDelaySeconds: 300
          periodSeconds: 300
          timeoutSeconds: 60
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: bytebase-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: bytebase-entrypoint
spec:
  type: ClusterIP
  selector:
    app: bytebase
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 8080
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: bytebase
spec:
  rules:
  - host: bytebase.jokerbai.com
    http:
      paths:
      - backend:
          serviceName: bytebase-entrypoint
          servicePort: 8080
        path: /
</code>

3. Verify Deployment

<code># kubectl get po -n bytebase
NAME                                 READY   STATUS    RESTARTS   AGE
bytebase-5559b7ff97-bmwc6           1/1     Running   0         5h18m
postgres-6989656975-5glhh           1/1     Running   0         5h20m
</code>

Usage Example

After the first login, create an administrator account as prompted, then you will see the main dashboard.

Bytebase dashboard
Bytebase dashboard

User Management

Bytebase supports manual user management and SSO integration. To configure SSO, navigate to Settings → SSO → Create SSO and fill in the required information.

SSO configuration
SSO configuration

After creating an application in GitLab, copy the generated ID and Secret back into Bytebase and update the GitLab URL.

GitLab app creation
GitLab app creation
GitLab app credentials
GitLab app credentials

Login via GitLab after configuration.

GitLab login
GitLab login

Instance Management

Add database instances in the "Instances" section. Provide the super‑admin credentials; Bytebase will create a dedicated

bytebase

database with a

migration_history

table to record all operations.

Add instance
Add instance

Bytebase automatically synchronizes the target database schema.

Schema sync
Schema sync

Database Management

Create or modify databases directly from the UI. For example, to add a

user

table, navigate to Database → Change Scheme, select the target database, and edit the schema.

Create table
Create table

After submitting, the SQL review may warn about missing default values; adjust the field accordingly.

SQL review warning
SQL review warning

Insert data using DML operations, e.g., add a row to the

user

table.

Insert data
Insert data

Project Management

Organize databases by projects. Create a new project (e.g., TEST), then transfer the

joker-test

database into it.

Create project
Create project
Transfer database
Transfer database

Add members to the project via Settings → Add Member.

Add members
Add members

Environment Management

Define environments (e.g., development, testing) to group instances, set approval policies, and configure backup strategies.

Environment settings
Environment settings

Conclusion

This article covered the basic deployment and core features of Bytebase for database CI/CD. Advanced topics such as fully integrating GitLab workflows will be addressed in a future post.

KubernetesdevopsGitLabPostgreSQLDatabase CI/CDBytebase
Ops Development Stories
Written by

Ops Development Stories

Maintained by a like‑minded team, covering both operations and development. Topics span Linux ops, DevOps toolchain, Kubernetes containerization, monitoring, log collection, network security, and Python or Go development. Team members: Qiao Ke, wanger, Dong Ge, Su Xin, Hua Zai, Zheng Ge, Teacher Xia.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.