Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.
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
16 changes: 15 additions & 1 deletion incubator/nginx/examples/nginx.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,23 @@ local nginx = import '../nginx.libsonnet';

local namespace = "dev-alex";
local appName = "nginx-app";
// sample configuration for php-fpm
// Note: must escape file path with extra \
local sbConfig = "server {
listen 0.0.0.0:80;
root /app;
location / {
index index.html index.php;
}
location ~ \\.php$ {
fastcgi_pass phpfpm-server:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}";

k.core.v1.list.new([
nginx.parts.deployment.withServerBlock(namespace, appName),
nginx.parts.service(namespace, appName),
nginx.parts.serverBlockConfigMap(namespace, appName),
nginx.parts.serverBlockConfigMap(namespace, appName, sbConfig),
])
2 changes: 1 addition & 1 deletion incubator/nginx/mixin.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nginx",
"version": "0.0.1",
"description": "TODO: YOUR DESCRIPTION HERE",
"description": "This library makes it easy to deploy a Nginx Server to your Kubernetes cluster using ksonnet prototypes. Each prototype is made up of a subset of the following preconfigured components: deployment, service, and network policy.",
"author": "ksonnet team <ksonnet-help@heptio.com>",
"contributors": [
{
Expand Down
22 changes: 2 additions & 20 deletions incubator/nginx/nginx.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -115,25 +115,7 @@ local container = deployment.mixin.spec.template.spec.containersType;
},
},

serverBlockConfigMap(namespace, name):: {
local defaults = {
// example PHP-FPM vhost
vhost:
|||
server {
listen 0.0.0.0:80;
root /app;
location / {
index index.html index.php;
}
location ~ \.php$ {
fastcgi_pass phpfpm-server:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
|||
},
serverBlockConfigMap(namespace, name, sbConfig):: {
apiVersion: "v1",
kind: "ConfigMap",
metadata: {
Expand All @@ -142,7 +124,7 @@ local container = deployment.mixin.spec.template.spec.containersType;
labels: { app: name },
},
data: {
"vhost.conf": defaults.vhost,
"vhost.conf": sbConfig,
},
},
},
Expand Down
16 changes: 8 additions & 8 deletions incubator/nginx/prototypes/nginx-server-block.jsonnet
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// @apiVersion 0.0.1
// @name io.ksonnet.pkg.nginx-server-block
// @description Deploys a simple, stateless nginx server with server blocks (roughly equivalent
// to nginx virtual hosts). The nginx container is deployed using a
// Kubernetes deployment, and is exposed to a network with a service.
// @param namespace string Namespace in which to put the application
// @param name string Name to give to all components.

// TODO: How should the ServerBlockConf be exposed to the user? Not quite sure what the default does except for setting web server to port 80.
// @description When generated and applied, this prototype deploys stateless nginx server with server blocks (roughly equivalent
// to Apache virtual hosts). The nginx container is deployed using a
// Kubernetes deployment, and is exposed to a network with a service. The configMap is used to specify the files served.
// @param namespace string Namespace to specify destination within cluster
// @param name string Name of app to attach as identifier to all parts
// @param sbConfig string Server block configuration data to store

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

local namespace = import 'param://namespace';
local appName = import 'param://name';
local serverBlockConfig = import 'param://serverblockconfig'

k.core.v1.list.new([
nginx.parts.deployment.withServerBlock(namespace, appName),
nginx.parts.service(namespace, appName),
nginx.parts.serverBlockConfigMap(namespace, appName),
nginx.parts.serverBlockConfigMap(namespace, appName, serverBlockConfig),
])
11 changes: 5 additions & 6 deletions incubator/nginx/prototypes/nginx-simple.jsonnet
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// @apiVersion 0.0.1
// @name io.ksonnet.pkg.nginx-simple
// @description Deploys a simple, stateless nginx server with server blocks (roughly equivalent
// to nginx virtual hosts). The nginx container is deployed using a
// Kubernetes deployment, and is exposed to a network with a service.
// @param namespace string Namespace in which to put the application
// @param name string Name to give to each of the components

// @description When generated and applied, this prototype deploys a stateless nginx web
// server. The nginx container is deployed using a Kubernetes deployment, and
// is exposed to a network through a service.
// @param namespace string Namespace to specify destination within cluster
// @param name string Name of app to attach as identifier to all parts

local k = import 'ksonnet.beta.2/k.libsonnet';
local nginx = import 'incubator/nginx/nginx.libsonnet';
Expand Down