diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index b45e5f4..ab93c7d 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -28,5 +28,7 @@ jobs: # Runs a set of commands using the runners shell - name: Run a multi-line script run: | - yarn test, + cd app1 + yarn install + yarn test echo test, and deploy your project. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b56b274 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +node_modules +build +npm-debug.log +.nyc +.env +.DS_Store +.idea +configmap +app3 + +/gitops/single-service/other/ diff --git a/app1/.dockerignore b/app1/.dockerignore new file mode 100644 index 0000000..eedf37b --- /dev/null +++ b/app1/.dockerignore @@ -0,0 +1,4 @@ +.env +node_modules +build +data/* \ No newline at end of file diff --git a/app1/Dockerfile b/app1/Dockerfile new file mode 100644 index 0000000..e13bba0 --- /dev/null +++ b/app1/Dockerfile @@ -0,0 +1,10 @@ +ARG BUILD_VAR="buildVar" +FROM node:20.18.0-alpine3.20 +LABEL authors="vitalii-codefresh" +WORKDIR app/ +COPY . . +EXPOSE 8002 +VOLUME /myvol +RUN yarn install && npm -g uninstall npm + +ENTRYPOINT ["node", "index.js"] diff --git a/app1/index.js b/app1/index.js new file mode 100644 index 0000000..5d2dd61 --- /dev/null +++ b/app1/index.js @@ -0,0 +1,76 @@ +const { log } = require('console'); +const express = require('express'); +const crypto = require(`crypto`); +const { appendFile, readFile } = require("fs/promises"); +const { readdirSync } = require("fs"); +const { resolve } = require("path"); +require('dotenv').config(); + +const router = express.Router(); +const port = process.env.PORT || 8000; +const serviceId = crypto.randomBytes(5).toString("hex"); +const resultFile = "./data/results.csv"; + +const app = express(); // Експортуємо цей екземпляр + + +router.get('/', (req, res) => { + res.statusCode = 200; + res.header("Content-Type", "application/json"); + res.json({ result: "hello", serviceId }); +}); + +router.get('/add', express.json(), async (req, res) => { + const body = req.body; + if (!body || typeof body.firstValue === 'undefined' || typeof body.secondValue === 'undefined') { + res.statusCode = 400; + res.send("body is required"); + return; + } + const firstValue = body.firstValue; + const secondValue = body.secondValue; + const result = firstValue + secondValue; + await writeResult(result, serviceId); + res.send({ result, serviceId }); +}); + +router.get('/getResults', async (req, res) => { + try { + const results = await readResults(); + res.json({ results, serviceId }); + } catch (e) { + res.statusCode = 500; + res.send("internal error"); + } +}); + +router.get('/getDir', async (req, res) => { + try { + const myPath = resolve(); + const files = readdirSync("./"); + const dataContent = readdirSync("./data"); + res.json({ files, dataContent, myPath, serviceId }); + } catch (e) { + res.statusCode = 500; + res.send("internal error"); + } +}); + +app.use("/app1", router); + +module.exports = { app }; + +if (require.main === module) { + app.listen(port, () => { + log(`server starts at port ${port}`, `id is - ${serviceId}`); + }); +} + + +async function writeResult(result, serviceId) { + await appendFile(resultFile, `${result};SERVICE_ID-${serviceId};` + "\n"); +} + +async function readResults() { + return readFile(resultFile, { encoding: "utf-8" }); +} \ No newline at end of file diff --git a/app1/package.json b/app1/package.json new file mode 100644 index 0000000..207dd31 --- /dev/null +++ b/app1/package.json @@ -0,0 +1,22 @@ +{ + "name": "simple-server", + "version": "1.0.0", + "description": "To make it easy for you to get started with GitLab, here's a list of recommended next steps.", + "main": "app1/index.js", + "scripts": { + "test": "npx jest " + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "dotenv": "^16.4.1", + "express": "^4.18.2", + "jest": "27.5.1", + "ip": "2.0.1" + }, + "devDependencies": { + "supertest": "^7.1.4" + }, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" +} diff --git a/app1/test/app1.test.js b/app1/test/app1.test.js new file mode 100644 index 0000000..ee506c6 --- /dev/null +++ b/app1/test/app1.test.js @@ -0,0 +1,85 @@ +const request = require('supertest'); +const { app } = require('../index'); + +jest.mock('fs/promises', () => ({ + appendFile: jest.fn(() => Promise.resolve()), + readFile: jest.fn(() => Promise.resolve('10;SERVICE_ID-abcde;\n20;SERVICE_ID-fghij;\n')), +})); + +jest.mock('fs', () => ({ + readdirSync: jest.fn((path) => { + if (path === './') return ['app.js', 'package.json', 'data']; + if (path === './data') return ['results.csv']; + return []; + }), +})); + +describe('Express App Tests', () => { + let server; + + beforeAll((done) => { + server = app.listen(0, done); + }); + afterAll((done) =>{ + server.close(done); + }); + + test('GET /app1/ should return hello and serviceId', async () => { + const res = await request(server).get('/app1/'); + expect(res.statusCode).toEqual(200); + expect(res.headers['content-type']).toMatch(/application\/json/); + expect(res.body.result).toEqual('hello'); + expect(res.body).toHaveProperty('serviceId'); + }); + + test('GET /app1/add with valid body should return sum and serviceId', async () => { + const res = await request(server) + .get('/app1/add') + .send({ firstValue: 5, secondValue: 3 }) + .set('Content-Type', 'application/json'); + + expect(res.statusCode).toEqual(200); + expect(res.body.result).toEqual(8); + expect(res.body).toHaveProperty('serviceId'); + expect(require('fs/promises').appendFile).toHaveBeenCalledWith( + './data/results.csv', + expect.stringContaining('8;SERVICE_ID-'), + ); + }); + + test('GET /app1/add without body should return 400', async () => { + const res = await request(server).get('/app1/add'); // Без .send() + expect(res.statusCode).toEqual(400); + expect(res.text).toEqual('body is required'); + }); + + test('GET /app1/add with missing firstValue should return 400', async () => { + const res = await request(server) + .get('/app1/add') + .send({ secondValue: 3 }) + .set('Content-Type', 'application/json'); + expect(res.statusCode).toEqual(400); + expect(res.text).toEqual('body is required'); + }); + + test('GET /app1/getResults should return results from file', async () => { + const res = await request(server).get('/app1/getResults'); + expect(res.statusCode).toEqual(200); + expect(res.body.results).toEqual('10;SERVICE_ID-abcde;\n20;SERVICE_ID-fghij;\n'); + expect(res.body).toHaveProperty('serviceId'); + // Перевіряємо, що readFile був викликаний + expect(require('fs/promises').readFile).toHaveBeenCalledWith( + './data/results.csv', + { encoding: 'utf-8' } + ); + }); + + test('GET /app1/getDir should return directory contents and path', async () => { + const res = await request(server).get('/app1/getDir'); + expect(res.statusCode).toEqual(200); + expect(res.body.files).toEqual(['app.js', 'package.json', 'data']); + expect(res.body.dataContent).toEqual(['results.csv']); + expect(res.body).toHaveProperty('myPath'); + expect(res.body).toHaveProperty('serviceId'); + }); +}); \ No newline at end of file diff --git a/app2/.dockerignore b/app2/.dockerignore new file mode 100644 index 0000000..f563bb1 --- /dev/null +++ b/app2/.dockerignore @@ -0,0 +1,3 @@ +.env +node_modules +build \ No newline at end of file diff --git a/app2/Dockerfile b/app2/Dockerfile new file mode 100644 index 0000000..43bc6e8 --- /dev/null +++ b/app2/Dockerfile @@ -0,0 +1,10 @@ +ARG BUILD_VAR="buildVar" +FROM node:20.11-alpine3.18 +LABEL authors="vitalii-codefresh" +WORKDIR app/ +COPY . . +EXPOSE 8010 +VOLUME /myvol +RUN ["npm", "i"] + +ENTRYPOINT ["node", "index2.js"] diff --git a/app2/index2.js b/app2/index2.js new file mode 100644 index 0000000..c1fdf04 --- /dev/null +++ b/app2/index2.js @@ -0,0 +1,38 @@ +const {log} = require('console'); +const express = require('express') +const crypto = require(`crypto`); +require('dotenv').config(); +const app1Host = process.env.APP1_HOST; +const router = express.Router(); +const port = 8010; +const serviceId = crypto.randomBytes(5).toString("hex"); +const app = express(); + +router.get('/', (req, res) => { + res.statusCode = 200; + res.header("Content-Type", "application/json"); + res.json({result: "hello", serviceId}); +}) + +router.get('/getRes', express.json(), async (req, res) => { + if (!app1Host) { + res.statusCode = 500; + res.send("APP1_HOST - variable was not set"); + return; + } + try { + const results = await (await fetch(`${app1Host}/getResults`)).json(); + res.send({results, serviceId}); + } catch (e) { + console.error(e) + res.statusCode = 500; + res.send("Internal error"); + } +}); + +app.use("/app2", router); + +app.listen(port, () => { + log(`server starts at port ${port}`, `id is - ${serviceId}`); + console.log("app1Host is :"+ app1Host); +}) diff --git a/app2/package-lock.json b/app2/package-lock.json new file mode 100644 index 0000000..fcee6ea --- /dev/null +++ b/app2/package-lock.json @@ -0,0 +1,707 @@ +{ + "name": "simple-server", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "simple-server", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "dotenv": "^16.4.1", + "express": "^4.18.2" + } + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" + }, + "node_modules/body-parser": { + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", + "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "dependencies": { + "bytes": "3.1.2", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.11.0", + "raw-body": "2.5.1", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", + "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", + "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/define-data-property": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.3.tgz", + "integrity": "sha512-h3GBouC+RPtNX2N0hHVLo2ZwPYurq8mLmXpOLTsw71gr7lHt5VaI4vVkDUNOfiWmm48JEXe3VM7PmLX45AMmmg==", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/dotenv": { + "version": "16.4.3", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.3.tgz", + "integrity": "sha512-II98GFrje5psQTSve0E7bnwMFybNLqT8Vu8JIFWRjsE3khyNUm/loZupuy5DVzG2IXf/ysxvrixYOQnM6mjD3A==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" + }, + "node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "dependencies": { + "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.18.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", + "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "1.20.1", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.5.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.2.0", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.7", + "qs": "6.11.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.18.0", + "serve-static": "1.15.0", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/finalhandler": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", + "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "statuses": "2.0.1", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", + "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.1.tgz", + "integrity": "sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/object-inspect": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", + "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/qs": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dependencies": { + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", + "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "node_modules/send": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", + "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "2.4.1", + "range-parser": "~1.2.1", + "statuses": "2.0.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/serve-static": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", + "dependencies": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.18.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/set-function-length": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.1.tgz", + "integrity": "sha512-j4t6ccc+VsKwYHso+kElc5neZpjtq9EnRICFZtWyBsLojhmeF/ZBd/elqm22WJh/BziDe/SBiOeAt0m2mfLD0g==", + "dependencies": { + "define-data-property": "^1.1.2", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.3", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + }, + "node_modules/side-channel": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.5.tgz", + "integrity": "sha512-QcgiIWV4WV7qWExbN5llt6frQB/lBven9pqliLXfGPB+K9ZYXxDozp0wLkHS24kWCm+6YXH/f0HhnObZnZOBnQ==", + "dependencies": { + "call-bind": "^1.0.6", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.4", + "object-inspect": "^1.13.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "engines": { + "node": ">= 0.8" + } + } + } +} diff --git a/app2/package.json b/app2/package.json new file mode 100644 index 0000000..afdbf47 --- /dev/null +++ b/app2/package.json @@ -0,0 +1,16 @@ +{ + "name": "simple-server", + "version": "1.0.0", + "description": "To make it easy for you to get started with GitLab, here's a list of recommended next steps.", + "main": "app1/index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "dotenv": "^16.4.1", + "express": "^4.18.2" + } +} diff --git a/gitops/k3dCluster.yaml b/gitops/k3dCluster.yaml new file mode 100644 index 0000000..6410bbd --- /dev/null +++ b/gitops/k3dCluster.yaml @@ -0,0 +1,14 @@ +apiVersion: k3d.io/v1alpha5 +kind: Simple +metadata: + name: mycluster-vitalii # name that you want to give to your cluster (will still be prefixed with `k3d-`) +servers: 1 # same as `--servers 1` +agents: 0 # same as `--agents 2` +image: rancher/k3s:v1.30.0-k3s1 +#ports: +# - port: 8080:80 # same as `--port '8080:80@loadbalancer'` +# nodeFilters: +# - loadbalancer + + +# k3d cluster create --config gitops/k3dCluster.yaml \ No newline at end of file diff --git a/gitops/single-service/.helmignore b/gitops/single-service/.helmignore new file mode 100644 index 0000000..898df48 --- /dev/null +++ b/gitops/single-service/.helmignore @@ -0,0 +1,24 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ + diff --git a/gitops/single-service/Chart.yaml b/gitops/single-service/Chart.yaml new file mode 100644 index 0000000..b58b4ba --- /dev/null +++ b/gitops/single-service/Chart.yaml @@ -0,0 +1,25 @@ +apiVersion: v2 +name: single-service +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 1.0.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.1" + diff --git a/gitops/single-service/new.yaml b/gitops/single-service/new.yaml new file mode 100644 index 0000000..e7300a8 --- /dev/null +++ b/gitops/single-service/new.yaml @@ -0,0 +1,29 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: new + finalizers: + - resources-finalizer.argocd.argoproj.io/foreground +spec: + project: default + source: + path: gitops/single-service + repoURL: https://github.com/vitalii-codefresh/simple-server.git + targetRevision: develop + destination: + name: in-cluster + namespace: server + syncPolicy: + automated: + prune: false + selfHeal: true + allowEmpty: false + syncOptions: + - PrunePropagationPolicy=foreground + - Replace=false + - PruneLast=false + - Validate=true + - CreateNamespace=true + - ApplyOutOfSyncOnly=false + - ServerSideApply=true + - RespectIgnoreDifferences=false diff --git a/gitops/single-service/templates/_helper.tpl b/gitops/single-service/templates/_helper.tpl new file mode 100644 index 0000000..0cba930 --- /dev/null +++ b/gitops/single-service/templates/_helper.tpl @@ -0,0 +1,7 @@ +{{- define "app1port" -}} +{{if eq .Values.app1.port 8000}} +- name: PORT + value: "{{.Values.app1.port}}" +{{- default 8000 -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/gitops/single-service/templates/app1/app1Deploy.yml b/gitops/single-service/templates/app1/app1Deploy.yml new file mode 100644 index 0000000..0705b8e --- /dev/null +++ b/gitops/single-service/templates/app1/app1Deploy.yml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: simple-deployment1 + labels: + app: simple-deployment1 +spec: + replicas: 3 + selector: + matchLabels: + app: app1 + template: + metadata: + labels: + app: app1 + spec: + containers: + - name: simple-server1 + image: {{.Values.app1.image}} + ports: + - containerPort: {{.Values.app1.port}} + env: + - name: PORT + value: "{{.Values.app1.port}}" + volumeMounts: + - name: results + mountPath: "/app/data" + volumes: + - name: results + persistentVolumeClaim: + claimName: results-claim diff --git a/gitops/single-service/templates/app1/app1Service.yml b/gitops/single-service/templates/app1/app1Service.yml new file mode 100644 index 0000000..2f624c1 --- /dev/null +++ b/gitops/single-service/templates/app1/app1Service.yml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: app1-service + labels: + owner: vitalii +spec: + selector: + app: app1 + ports: + - protocol: TCP + port: 80 + targetPort: 8002 + name: http + type: ClusterIP \ No newline at end of file diff --git a/gitops/single-service/templates/app2/app2Deploy.yml b/gitops/single-service/templates/app2/app2Deploy.yml new file mode 100644 index 0000000..fe8b749 --- /dev/null +++ b/gitops/single-service/templates/app2/app2Deploy.yml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: simple-deployment2 + labels: + app: simple-deployment2 +spec: + replicas: {{ .Values.replicaCount}} + selector: + matchLabels: + app: app2 + template: + metadata: + labels: + app: app2 + spec: + containers: + - name: simple-server2 + image: {{.Values.app2.image}} + ports: + - containerPort: 8010 + env: + - name: APP1_HOST + value: {{ .Values.app2.app1host | quote }} diff --git a/gitops/single-service/templates/app2/app2Service.yml b/gitops/single-service/templates/app2/app2Service.yml new file mode 100644 index 0000000..a2748f2 --- /dev/null +++ b/gitops/single-service/templates/app2/app2Service.yml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: app2-service + labels: + owner: vitalii +spec: + selector: + app: app2 + ports: + - protocol: TCP + port: 80 + targetPort: 8010 + name: http + type: ClusterIP \ No newline at end of file diff --git a/gitops/single-service/templates/ingress.yml b/gitops/single-service/templates/ingress.yml new file mode 100644 index 0000000..76d7ff3 --- /dev/null +++ b/gitops/single-service/templates/ingress.yml @@ -0,0 +1,26 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: local-ingress + annotations: + target: / +spec: + ingressClassName: nginx-public + rules: + #- host: single-service-vitalii.rnd-sandbox.cf-infra.com + - http: + paths: + - path: /app1 + pathType: Prefix + backend: + service: + name: app1-service + port: + name: http + - path: /app2 + pathType: Prefix + backend: + service: + name: app2-service + port: + name: http diff --git a/gitops/single-service/templates/myVol/app1Volumes.yml b/gitops/single-service/templates/myVol/app1Volumes.yml new file mode 100644 index 0000000..562de23 --- /dev/null +++ b/gitops/single-service/templates/myVol/app1Volumes.yml @@ -0,0 +1,27 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: my-pv-volume + labels: + type: local +spec: + storageClassName: local-path + capacity: + storage: 0.09Gi + accessModes: + - ReadWriteMany + hostPath: + path: "/mnt/data" + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: results-claim +spec: + storageClassName: local-path + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 0.08Gi diff --git a/gitops/single-service/values.yaml b/gitops/single-service/values.yaml new file mode 100644 index 0000000..86f1ecb --- /dev/null +++ b/gitops/single-service/values.yaml @@ -0,0 +1,12 @@ +# Default values for single-service. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 +app1: + port: 8002 + image: vitaliicodefresh/app1:develop + +app2: + app1host: http://app1-service/app1 + image: vitaliicodefresh/app2:develop