Giter VIP home page Giter VIP logo

Comments (5)

silvestre avatar silvestre commented on June 10, 2024 1

The App Autoscaler meanwhile has gained MySQL support.

from app-autoscaler.

cf-gitbot avatar cf-gitbot commented on June 10, 2024

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/140075095

The labels on this github issue will be updated when the story is started.

from app-autoscaler.

software-engineer-mj avatar software-engineer-mj commented on June 10, 2024

Is there anyone working on this? I am interested in contributing to support for MySQL.

from app-autoscaler.

boyang9527 avatar boyang9527 commented on June 10, 2024

Please go ahead with it... we don't have efforts on it right now...

from app-autoscaler.

software-engineer-mj avatar software-engineer-mj commented on June 10, 2024

Design Notes - Support for MySQL

I have successfully deployed app-autoscaler with MySQL.
I'd like to share how I did it before I create a pull request.

Why Support for MySQL?

If you are running Cloud Foundry with mysql, you do not need to deploy and manage a postgres database.

[Pseudo Codes] App AutoScaler

Install Go MySQL Driver

source .envrc
go get github.com/go-sql-driver/mysql

Import Go MySQL Driver

[Postgres] _ "github.com/lib/pq"
[MySQL] _ "github.com/go-sql-driver/mysql"

Add Liquibase MySQL Dependency

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.36</version>
</dependency>

Change DB Propertities

autoscaler/db/db.go

[Postgres] const PostgresDriverName = "postgres"
[MySQL] const DatasourceDriverName = "mysql"

DB Tables - Modify Value & Varchar Column Length

[Postgres] value: json
[MySQL] value: text

[Postgres] type: varchar
[MySQL] type: varchar(255) 

DDL

[Postgres] INSERT INTO table(col1, col2, col3, col4, col5) values($1, $2, $3, $4, $5)
[MySQL] INSERT INTO table(col1, col2, col3, col4, col5) values(?, ?, ?, ?, ?)

[Pseudo Codes] App AutoScaler Release

Install Node MySQL Package - API Server & Service Broker (pre_packaging)

npm install mysql

Modify property-overrides.yml

---
default_db: 
  databases:
    - {name: autoscaler, tag: default}
  db_scheme: mysql
  port: 3306
  roles:
    - {name: root, password: password, tag: default}

Modify bosh-lite-manifest-template-v1.yml

  - name: cf-mysql
    url: https://bosh.io/d/github.com/cloudfoundry/cf-mysql-release?v=32
    version: '32'
    sha1: a41bb2cadd4311bc9977ccc2c1fca07ba41ccef2
jobs:
  - name: mysql 
    instances: (( instance_count_overrides.mysql.instances || 1 ))
    update:
      serial: true
    resource_pool: default
    networks:
      - name: default
    templates:
      - name: consul_agent
        release: cf
        consumes: {consul_client: nil, consul_server: nil, consul_common: nil}
      - name: mysql
        release: cf-mysql
    properties:
      cf_mysql:
        mysql:
          admin_password: password
          port: 3306
          binlog_enabled: false
          cluster_health:
            password: password
          galera_healthcheck:
            db_password: password
            endpoint_username: galera_healthcheck
            endpoint_password: password
          seeded_databases:
          - name: autoscaler
            username: root
            password: password
      consul:
        agent:
          mode: client
          services:
            mysql:
              check:
                tcp: 127.0.0.1:3306
                interval: 30s
                timeout: 10s

Modify Packages & Jobs

packages/{component}/spec

- app-autoscaler/src/github.com/go-sql-driver/mysql/*.go

jobs/{component}/templates/pre-start.erb

[Postgres] java -cp "/var/vcap/packages/db/target/lib/*" liquibase.integration.commandline.Main --url jdbc:postgresql://$HOST:$PORT/$DBNAME --username=$USER --password=$PASSWORD \
--driver=org.postgresql.Driver --changeLogFile=/var/vcap/packages/eventgenerator/dataaggregator.db.changelog.yml update

[MySQL] java -cp "/var/vcap/packages/db/target/lib/*" liquibase.integration.commandline.Main --url jdbc:mysql://$HOST:$PORT/$DBNAME --username=$USER --password=$PASSWORD \
--driver=com.mysql.jdbc.Driver --changeLogFile=/var/vcap/packages/eventgenerator/dataaggregator.db.changelog.yml update

jobs/{component}/spec (IP address on which the db server will listen)

[Postgres] postgres.service.cf.internal
[MySQL] mysql.service.cf.internal

jobs/{component}/templates/{component}.yml.erb

[Postgres] db_url = db_scheme://db_role['name']:db_role['password']@db_address:db_port.to_s/db_database['name']?sslmode=disable
[MySQL] db_url = db_role['name'] :db_role['password']@tcp(db_address:db_port.to_s)/db_database['name'] 

from app-autoscaler.

Related Issues (20)

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.