diff --git a/incubator/mariadb/README.md b/incubator/mariadb/README.md index a0ef8fc..a918c0a 100644 --- a/incubator/mariadb/README.md +++ b/incubator/mariadb/README.md @@ -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 @@ -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 @@ -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 diff --git a/incubator/mariadb/maria.libsonnet b/incubator/mariadb/maria.libsonnet index 695a64c..875fcf1 100644 --- a/incubator/mariadb/maria.libsonnet +++ b/incubator/mariadb/maria.libsonnet @@ -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", @@ -88,7 +88,7 @@ local deployment = k.extensions.v1beta1.deployment; storage: defaults.size, }, }, - [if storageClassName != null then "storageClass"]:storageClassName, + storageClass:storageClassName, }, }, @@ -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: { @@ -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) = [ diff --git a/incubator/mariadb/mixin.yaml b/incubator/mariadb/mixin.yaml index 6c1c1b9..22a2a2d 100644 --- a/incubator/mariadb/mixin.yaml +++ b/incubator/mariadb/mixin.yaml @@ -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 ", "contributors": [ { @@ -36,4 +36,5 @@ "comment": "Run a simple mariadb database" }, "license": "Apache 2.0" -} \ No newline at end of file +} + diff --git a/incubator/mariadb/prototypes/persistent/maria-persistent.jsonnet b/incubator/mariadb/prototypes/persistent/maria-persistent.jsonnet new file mode 100644 index 0000000..6a29466 --- /dev/null +++ b/incubator/mariadb/prototypes/persistent/maria-persistent.jsonnet @@ -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) + ]) + diff --git a/incubator/mariadb/prototypes/maria-stateless.jsonnet b/incubator/mariadb/prototypes/stateless/maria-stateless.jsonnet similarity index 50% rename from incubator/mariadb/prototypes/maria-stateless.jsonnet rename to incubator/mariadb/prototypes/stateless/maria-stateless.jsonnet index a26925f..72e746d 100644 --- a/incubator/mariadb/prototypes/maria-stateless.jsonnet +++ b/incubator/mariadb/prototypes/stateless/maria-stateless.jsonnet @@ -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) ])