Skip to content

Commit 8d8ac67

Browse files
committed
init
0 parents  commit 8d8ac67

18 files changed

+25613
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
dist/

.npmignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.DS_Store
2+
.idea
3+
.vscode
4+
npm-debug.log
5+
yarn-error.log
6+
node_modules
7+
*.map
8+
example
9+
test
10+
dist
11+
circle.yml
12+
ARCHITECTURE.md
13+
CONTRIBUTING.md
14+
.editorconfig
15+
package-lock.json
16+
yarn.lock

Budfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
# Convert the JSON schema to a TypeScript interface
4+
function convert_kube_json_schema() {
5+
rm _definitions.json
6+
wget https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.27.2/_definitions.json
7+
sed -i 's/\(io.k8s[^"]*\)\(\"\)/\1\.\2/' _definitions.json # Append a dot to all io.k8s definitions so that interface names are generated correctly
8+
./node_modules/json-schema-to-typescript/dist/src/cli.js kube-spec.json > kubeTypes.ts
9+
}
10+
11+
# Convert the JSON schema to a TypeScript interface
12+
function convert_compose_json_schema() {
13+
./node_modules/json-schema-to-typescript/dist/src/cli.js compose-spec.json > composeTypes.ts
14+
}

README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# docker2kube (d2k)
2+
3+
d2k is a typescript library that converts docker-compose YAML files to Kubernetes YAML file. The goal is to make it painless to deploy docker-deployable project on Kubernetes.
4+
5+
# Installation
6+
NPM: `npm i docker2kube`
7+
8+
YARN: `yarn add docker2kube`
9+
10+
# Usage
11+
```javascript
12+
import { convert } from 'docker2kube';
13+
14+
const composeYaml = `\
15+
version: '3'
16+
17+
services:
18+
nginx:
19+
image: nginx:latest
20+
ports:
21+
- "80:80"
22+
volumes:
23+
- ./nginx.conf:/etc/nginx/nginx.conf
24+
restart: always
25+
`;
26+
27+
const output = convert(composeYaml);
28+
console.log(output);
29+
```
30+
31+
32+
# Acknowledgment
33+
34+
* [kompose](https://github.com/kubernetes/kompose) is the canonical tool for converting docker-compose templates. And inspired this project.
35+
* [json-schema-to-typescript](https://github.com/bcherny/json-schema-to-typescript) makes working with JSON schema a dream.

_definitions.json

+17,087
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)