Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Simple Maria Prototype: Deployment, PVC, Secret, Service #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions incubator/mariadb/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# mariadb

> MariaDB is an open source relational database it provides a SQL interface for accessing data. The latest versions of MariaDB also include GIS and JSON features. This package deploys a maria container, a service and secret to your cluster
> MariaDB is an open source relational database it provides a SQL interface for accessing data. This library makes it easy to deploy a Mariadb app to your Kubernetes cluster using ksonnet prototypes. Each prototype is made up of a subset of the following preconfigured components: deployment, persistent volume claim, service, secret, and configMap.

* [Quickstart](#quickstart)
* [Using Prototypes](#using-prototypes)
* [io.ksonnet.pkg.stateless-maria](#io.ksonnet.pkg.stateless-maria)
* [io.ksonnet.pkg.persistent-maria](#io.ksonnet.pkg.persistent-maria)

## Quickstart

Expand All @@ -20,9 +20,9 @@ Finally, in the ksonnet application directory, run the following:
# Expand prototype as a Jsonnet file, place in a file in the
# `components/` directory. (YAML and JSON are also available.)
$ ks prototype use io.ksonnet.pkg.simple-mariadb mariadb \
--name mariadb \
--namespace default \
--mariaRootPassword boot
--mariaRootPassword boot \
--name mariadb

# Apply to server.
$ ks apply -f mariadb.jsonnet
Expand All @@ -36,17 +36,18 @@ This library provides a set of pre-fabricated "flavors" (or "distributions") of

These prototypes, as well as how to use them, are enumerated below.

### io.ksonnet.pkg.stateless-maria
### io.ksonnet.pkg.persistent-maria

Deploy stateless instance of MariaDB. This is NOT backed by a persistent volume.The MariaDB container is deployed using a deployment and exposed to the
network as a service. The password is stored as a secret.
MariaDB is an open source relational database it provides a SQL interface foraccessing data. The latest versions of MariaDB also include GIS and JSON
features. This package deploys a maria container backed by a mounted
persistent volume claim, a secret, and service to expose your deployment.

#### Example

```shell
# Expand prototype as a Jsonnet file, place in a file in the
# `components/` directory. (YAML and JSON are also available.)
$ ks prototype use io.ksonnet.pkg.stateless-maria mariadb \
$ ks prototype use io.ksonnet.pkg.persistent-maria mariadb \
--namespace YOUR_NAMESPACE_HERE \
--name YOUR_NAME_HERE \
--mariaRootPassword YOUR_MARIAROOTPASSWORD_HERE
Expand Down
8 changes: 4 additions & 4 deletions incubator/mariadb/maria.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local deployment = k.extensions.v1beta1.deployment;

{
parts:: {
svc(namespace, name, metricsEnabled=true, labels={app:name}, selector={app:name})::
svc(namespace, name, metricsEnabled=false, labels={app:name}, selector={app:name})::
{
apiVersion: "v1",
kind: "Service",
Expand Down Expand Up @@ -88,7 +88,7 @@ local deployment = k.extensions.v1beta1.deployment;
storage: defaults.size,
},
},
[if storageClassName != null then "storageClass"]:storageClassName,
storageClass:storageClassName,
},
},

Expand Down Expand Up @@ -123,7 +123,7 @@ local deployment = k.extensions.v1beta1.deployment;
},
},

persistent(namespace, name, passwordSecretName, mariaConfig=defaults.mariaConfig, metricsEnabled=true, existingClaim=name, labels={app:name}, configMapName=name)::
persistent(namespace, name, passwordSecretName, mariaConfig=defaults.mariaConfig, metricsEnabled=false, existingClaim=name, labels={app:name}, configMapName=name)::
local volume = {
name: "data",
persistentVolumeClaim: {
Expand All @@ -133,7 +133,7 @@ local deployment = k.extensions.v1beta1.deployment;
base(namespace, name, passwordSecretName, mariaConfig, metricsEnabled, existingClaim, labels, configMapName) +
deployment.mixin.spec.template.spec.volumes(volume),

nonPersistent(namespace, name, passwordSecretName, mariaConfig=defaults.mariaConfig, metricsEnabled=true, existingClaim=name, labels={app:name}, configMapName=name)::
nonPersistent(namespace, name, passwordSecretName, mariaConfig=defaults.mariaConfig, metricsEnabled=false, existingClaim=name, labels={app:name}, configMapName=name)::
base(namespace, name, passwordSecretName, mariaConfig, metricsEnabled, existingClaim, labels, configMapName),

local secure(passwordSecretName) = [
Expand Down
5 changes: 3 additions & 2 deletions incubator/mariadb/mixin.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mariadb",
"version": "0.0.1",
"description": "MariaDB is an open source relational database it provides a SQL interface for accessing data. The latest versions of MariaDB also include GIS and JSON features. This package deploys a maria container, a service and secret to your cluster",
"description": "MariaDB is an open source relational database it provides a SQL interface for accessing data. This library makes it easy to deploy a Mariadb app to your Kubernetes cluster using ksonnet prototypes. Each prototype is made up of a subset of the following preconfigured components: deployment, persistent volume claim, service, secret, and configMap.",
"author": "ksonnet team <[email protected]>",
"contributors": [
{
Expand Down Expand Up @@ -36,4 +36,5 @@
"comment": "Run a simple mariadb database"
},
"license": "Apache 2.0"
}
}

28 changes: 28 additions & 0 deletions incubator/mariadb/prototypes/persistent/maria-persistent.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// @apiVersion 0.1
// @name io.ksonnet.pkg.persistent-maria
// @description MariaDB is an open source relational database it provides a SQL interface for
// accessing data. The latest versions of MariaDB also include GIS and JSON
// features. This package deploys a maria container backed by a mounted
// persistent volume claim, a secret, and service to expose your deployment.
// @param namespace string Namespace to specify destination within cluster, defaults to 'default'
// @param name string Metadata name for each of the deployment components
// @param mariaRootPassword string Password for root user

local k = import 'ksonnet.beta.2/k.libsonnet';
local maria = import '../../maria.libsonnet';

local namespace = "import 'param://namespace'";
local name = "import 'param://name'";
local mariaRootPassword = "import 'param://mariaRootPassword'";
local passwordSecretName = "import 'param://passwordSecretName/name' ";

local labels = "import 'param://labels/{app:name}'";
local selector = "import 'param://labels/{app:name}'";

k.core.v1.list.new([
maria.parts.deployment.persistent(namespace, name, passwordSecretName),
maria.parts.pvc(namespace, name),
maria.parts.secret(namespace, name, mariaRootPassword),
maria.parts.svc(namespace, name)
])

Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
// @apiVersion 0.1
// @name io.ksonnet.pkg.stateless-maria
// @description Deploy stateless instance of MariaDB. This is NOT backed by a persistent volume.
// The MariaDB container is deployed using a deployment and exposed to the
// network as a service. The password is stored as a secret.
// @description MariaDB is an open source relational database it provides a SQL interface for
// accessing data. This MariaDB mixin library contains Ksonnet prototypes of preconfigured
// components to help you easily deploy a MariaDB app to your Kubernetes cluster.
// @param namespace string Namespace in which to put the application
// @param name string Metadata name for each of the deployment components
// @param mariaRootPassword string Password for root user

local k = import 'ksonnet.beta.2/k.libsonnet';
local maria = import 'incubator/mariadb/maria.libsonnet';
local maria = import '../../maria.libsonnet';

local namespace = "import 'param://namespace'";
local name = "import 'param://name'";
local mariaRootPassword = "import 'param://mariaRootPassword'";
local passwordSecretName = "import 'param://passwordSecretName/name' ";

local labels = "import 'param://labels/{app:name}'";
local selector = "import 'param://labels/{app:name}'";

k.core.v1.list.new([
maria.parts.deployment.nonPersistent(namespace, name, name),
maria.parts.deployment.nonPersistent(namespace, name, passwordSecretName),
maria.parts.secret(namespace, name, mariaRootPassword),
maria.parts.svc(namespace, name)
])
Expand Down