Skip to content

Commit

Permalink
Add proxysql (chainguard-images#981)
Browse files Browse the repository at this point in the history
* Add proxysql

Signed-off-by: Furkan Türkal <[email protected]>
Co-authored-by: Batuhan <[email protected]>

* refactor tests

Signed-off-by: Batuhan Apaydin <[email protected]>

---------

Signed-off-by: Furkan Türkal <[email protected]>
Signed-off-by: Batuhan Apaydin <[email protected]>
Co-authored-by: Batuhan <[email protected]>
  • Loading branch information
Dentrax and developer-guy authored Jul 6, 2023
1 parent 3bcc00a commit a715fb4
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
| [postgres](./images/postgres) | `cgr.dev/chainguard/postgres` | stable | [![](https://storage.googleapis.com/chainguard-images-build-outputs/badges/postgres.build.status.latest.svg)](https://registry-ui.chainguard.app/?image=cgr.dev/chainguard/postgres:latest) |
| [powershell](./images/powershell) | `cgr.dev/chainguard/powershell` | experimental | [![](https://storage.googleapis.com/chainguard-images-build-outputs/badges/powershell.build.status.latest.svg)](https://registry-ui.chainguard.app/?image=cgr.dev/chainguard/powershell:latest) |
| [prometheus](./images/prometheus) | `cgr.dev/chainguard/prometheus` | stable | [![](https://storage.googleapis.com/chainguard-images-build-outputs/badges/prometheus.build.status.latest.svg)](https://registry-ui.chainguard.app/?image=cgr.dev/chainguard/prometheus:latest) |
| [proxysql](./images/proxysql) | `cgr.dev/chainguard/proxysql` | stable | [![](https://storage.googleapis.com/chainguard-images-build-outputs/badges/proxysql.build.status.latest.svg)](https://registry-ui.chainguard.app/?image=cgr.dev/chainguard/proxysql:latest) |
| [pulumi](./images/pulumi) | `cgr.dev/chainguard/pulumi` | stable | [![](https://storage.googleapis.com/chainguard-images-build-outputs/badges/pulumi.build.status.latest.svg)](https://registry-ui.chainguard.app/?image=cgr.dev/chainguard/pulumi:latest) |
| [python](./images/python) | `cgr.dev/chainguard/python` | stable | [![](https://storage.googleapis.com/chainguard-images-build-outputs/badges/python.build.status.3.11.svg)](https://registry-ui.chainguard.app/?image=cgr.dev/chainguard/python:3.11) |
| [rabbitmq](./images/rabbitmq) | `cgr.dev/chainguard/rabbitmq` | experimental | [![](https://storage.googleapis.com/chainguard-images-build-outputs/badges/rabbitmq.build.status.latest.svg)](https://registry-ui.chainguard.app/?image=cgr.dev/chainguard/rabbitmq:latest) |
Expand Down
100 changes: 100 additions & 0 deletions images/proxysql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<!--monopod:start-->
# proxysql
| | |
| - | - |
| **Status** | stable |
| **OCI Reference** | `cgr.dev/chainguard/proxysql` |


* [View Image in Chainguard Academy](https://edu.chainguard.dev/chainguard/chainguard-images/reference/proxysql/overview/)
* [View Image Catalog](https://console.enforce.dev/images/catalog) for a full list of available tags.
*[Contact Chainguard](https://www.chainguard.dev/chainguard-images) for enterprise support, SLAs, and access to older tags.*

---
<!--monopod:end-->

Minimal image with [proxysql](https://github.com/sysown/proxysql).

## Get It!

The image is available on `cgr.dev`:

```
docker pull cgr.dev/chainguard/proxysql:latest
```

## Usage

With `Helm`:

```shell
helm repo add dysnix https://dysnix.github.io/charts/
helm repo update
helm install proxysql dysnix/proxysql \
--namespace proxysql \
--create-namespace \
--set image.registry=cgr.dev \
--set image.repository=chainguard/proxysql \
--set image.tag=latest \
--wait
```

Please note that [official Helm chart](https://github.com/ProxySQL/kubernetes/tree/master) is outdated and no longer maintaining.

With `Docker`:

```shell
$ docker run cgr.dev/chainguard/proxysql:latest
2023-06-28 13:27:29 [INFO] Using config file /etc/proxysql.cnf
Renaming database file /var/lib/proxysql/proxysql.db
2023-06-28 13:27:29 [INFO] Current RLIMIT_NOFILE: 1048576
2023-06-28 13:27:29 [INFO] Using OpenSSL version: OpenSSL 3.1.0 14 Mar 2023
2023-06-28 13:27:29 [INFO] No SSL keys/certificates found in datadir (/var/lib/proxysql). Generating new keys/certificates.
2023-06-28 13:27:29 [INFO] ProxySQL version 2.5.3-89-g86ce115
2023-06-28 13:27:29 [INFO] Detected OS: Linux d90ca7f378f8 5.15.49-linuxkit-pr #1 SMP PREEMPT Thu May 25 07:27:39 UTC 2023 aarch64
2023-06-28 13:27:29 [INFO] ProxySQL SHA1 checksum: 491223ebbd1a1dd43c69f24cefa2b269dde73162
2023-06-28 13:27:29 [INFO] SSL keys/certificates found in datadir (/var/lib/proxysql): loading them.
2023-06-28 13:27:29 [INFO] Loaded built-in SQLite3
Standard ProxySQL MySQL Logger rev. 2.5.0421 -- MySQL_Logger.cpp -- Thu Jun 22 15:09:08 2023
Standard ProxySQL Cluster rev. 0.4.0906 -- ProxySQL_Cluster.cpp -- Thu Jun 22 15:09:08 2023
Standard ProxySQL Statistics rev. 1.4.1027 -- ProxySQL_Statistics.cpp -- Thu Jun 22 15:09:08 2023
Standard ProxySQL HTTP Server Handler rev. 1.4.1031 -- ProxySQL_HTTP_Server.cpp -- Thu Jun 22 15:09:08 2023
2023-06-28 13:27:29 [INFO] Using UUID: 588c8cc0-1168-46e5-93b9-c53a0923686f , randomly generated. Writing it to database
2023-06-28 13:27:29 [INFO] Computed checksum for 'LOAD ADMIN VARIABLES TO RUNTIME' was '0x3A8D4652D65FCE60', with epoch '1687958849'
2023-06-28 13:27:29 [INFO] Computed checksum for 'LOAD MYSQL VARIABLES TO RUNTIME' was '0xAA126AC5C26167ED', with epoch '1687958849'
Standard ProxySQL Admin rev. 2.0.6.0805 -- ProxySQL_Admin.cpp -- Thu Jun 22 15:09:08 2023
2023-06-28 13:27:29 [INFO] ProxySQL SHA1 checksum: 491223ebbd1a1dd43c69f24cefa2b269dde73162
Standard MySQL Threads Handler rev. 0.2.0902 -- MySQL_Thread.cpp -- Thu Jun 22 15:09:08 2023
Standard MySQL Authentication rev. 0.2.0902 -- MySQL_Authentication.cpp -- Thu Jun 22 15:09:08 2023
2023-06-28 13:27:29 [INFO] Computed checksum for 'LOAD MYSQL USERS TO RUNTIME' was '0x0000000000000000', with epoch '1687958849'
2023-06-28 13:27:29 [INFO] Dumping mysql_servers_incoming
+--------------+----------+------+-----------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| hostgroup_id | hostname | port | gtid_port | weight | status | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+----------+------+-----------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
+--------------+----------+------+-----------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
2023-06-28 13:27:29 [INFO] Dumping mysql_servers LEFT JOIN mysql_servers_incoming
+-------------+--------------+----------+------+
| mem_pointer | hostgroup_id | hostname | port |
+-------------+--------------+----------+------+
+-------------+--------------+----------+------+
2023-06-28 13:27:29 [INFO] Dumping mysql_servers JOIN mysql_servers_incoming
+--------------+----------+------+-----------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+-------------+-----------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| hostgroup_id | hostname | port | gtid_port | weight | status | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment | mem_pointer | gtid_port | weight | status | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+----------+------+-----------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+-------------+-----------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
+--------------+----------+------+-----------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+-------------+-----------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
2023-06-28 13:27:29 [INFO] New mysql_group_replication_hostgroups table
2023-06-28 13:27:29 [INFO] New mysql_galera_hostgroups table
2023-06-28 13:27:29 [INFO] New mysql_aws_aurora_hostgroups table
2023-06-28 13:27:29 [INFO] New mysql_hostgroup_attributes table
2023-06-28 13:27:29 [INFO] MySQL_HostGroups_Manager::commit() locked for 3ms
2023-06-28 13:27:29 [INFO] Computed checksum for 'LOAD PROXYSQL SERVERS TO RUNTIME' was '0x0000000000000000', with epoch '1687958849'
Standard Query Processor rev. 2.0.6.0805 -- Query_Processor.cpp -- Thu Jun 22 15:09:08 2023
2023-06-28 13:27:29 [INFO] Computed checksum for 'LOAD MYSQL QUERY RULES TO RUNTIME' was '0x0000000000000000', with epoch '1687958849'
In memory Standard Query Cache (SQC) rev. 1.2.0905 -- Query_Cache.cpp -- Thu Jun 22 15:09:08 2023
Standard MySQL Monitor (StdMyMon) rev. 2.0.1226 -- MySQL_Monitor.cpp -- Thu Jun 22 15:09:08 2023
2023-06-28 13:27:29 [INFO] For information about products and services visit: https://proxysql.com/
2023-06-28 13:27:29 [INFO] For online documentation visit: https://proxysql.com/documentation/
2023-06-28 13:27:29 [INFO] For support visit: https://proxysql.com/services/support/
2023-06-28 13:27:29 [INFO] For consultancy visit: https://proxysql.com/services/consulting/
2023-06-28 13:27:29 [INFO] Latest ProxySQL version available: 2.5.3-89-g86ce115
```
28 changes: 28 additions & 0 deletions images/proxysql/configs/latest.apko.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
contents:
packages:
- proxysql

accounts:
groups:
- groupname: proxysql
gid: 65532
users:
- username: proxysql
uid: 65532
recursive: true

entrypoint:
command: /usr/bin/proxysql
cmd: --initial --idle-threads -f -c /etc/proxysql.cnf

paths:
- path: /var/lib/proxysql
type: directory
uid: 65532
gid: 65532
permissions: 0o755

annotations:
"org.opencontainers.image.authors": "Chainguard Team https://www.chainguard.dev/"
"org.opencontainers.image.url": https://edu.chainguard.dev/chainguard/chainguard-images/reference/proxysql/
"org.opencontainers.image.source": https://github.com/chainguard-images/images/tree/main/images/proxysql
3 changes: 3 additions & 0 deletions images/proxysql/image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
- apko:
config: configs/latest.apko.yaml
56 changes: 56 additions & 0 deletions images/proxysql/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
terraform {
required_providers {
apko = { source = "chainguard-dev/apko" }
}
}

variable "target_repository" {
description = "The docker repo into which the image and attestations should be published."
}

module "latest" {
source = "../../tflib/publisher"

target_repository = var.target_repository
config = file("${path.module}/configs/latest.apko.yaml")
}

module "dev" { source = "../../tflib/dev-subvariant" }

module "latest-dev" {
source = "../../tflib/publisher"

target_repository = var.target_repository
config = jsonencode(module.latest.config)
extra_packages = module.dev.extra_packages
}

module "version-tags" {
source = "../../tflib/version-tags"
package = "proxysql"
config = module.latest.config
}

module "test-latest" {
source = "./tests"
digest = module.latest.image_ref
}

module "test-latest-dev" {
source = "./tests"
digest = module.latest-dev.image_ref
}

module "tagger" {
source = "../../tflib/tagger"

depends_on = [
module.test-latest,
module.test-latest-dev,
]

tags = merge(
{ for t in toset(concat(["latest"], module.version-tags.tag_list)) : t => module.latest.image_ref },
{ for t in toset(concat(["latest"], module.version-tags.tag_list)) : "${t}-dev" => module.latest-dev.image_ref },
)
}
38 changes: 38 additions & 0 deletions images/proxysql/tests/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
terraform {
required_providers {
oci = { source = "chainguard-dev/oci" }
random = { source = "hashicorp/random" }
helm = { source = "hashicorp/helm" }
}
}

variable "digest" {
description = "The image digest to run tests over."
}


# we commented out the Helm tests since the Helm Chart uses the tag in labels, so, once we use pseudo tag, it gives an error like the following:
# [metadata.labels: Invalid value: "unused@sha256:d92268eff1c19eba6c809303294c5041d98f793746d5f5a0212519391fce3b22": must be no more than 63 characters
# https://github.com/dysnix/charts/blob/main/dysnix/proxysql/templates/_helpers.tpl?rgh-link-date=2023-07-06T13%3A57%3A36Z#L41

# data "oci_string" "ref" { input = var.digest }

# resource "random_pet" "suffix" {}

# resource "helm_release" "proxysql" {
# name = "proxysql-${random_pet.suffix.id}"

# repository = "https://dysnix.github.io/charts/"
# chart = "proxysql"

# create_namespace = true
# namespace = "proxysql-${random_pet.suffix.id}"

# values = [jsonencode({
# image = {
# registry = data.oci_string.ref.registry
# repository = data.oci_string.ref.repo
# tag = data.oci_string.ref.pseudo_tag
# }
# })]
# }
5 changes: 5 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,11 @@ module "prometheus" {
target_repository = "${var.target_repository}/prometheus"
}

module "proxysql" {
source = "./images/proxysql"
target_repository = "${var.target_repository}/proxysql"
}

module "pulumi" {
source = "./images/pulumi"
target_repository = "${var.target_repository}/pulumi"
Expand Down

0 comments on commit a715fb4

Please sign in to comment.