{"id":28194323,"url":"https://github.com/monkey-projects/deploy-inst","last_synced_at":"2025-09-02T15:02:30.298Z","repository":{"id":246355313,"uuid":"820839670","full_name":"monkey-projects/deploy-inst","owner":"monkey-projects","description":"Provides functionality to update OCI container instances and redirect backends","archived":false,"fork":false,"pushed_at":"2024-08-22T12:35:07.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-22T14:08:35.310Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/monkey-projects.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-27T09:26:55.000Z","updated_at":"2024-08-22T12:35:11.000Z","dependencies_parsed_at":"2024-06-27T11:11:46.827Z","dependency_job_id":null,"html_url":"https://github.com/monkey-projects/deploy-inst","commit_stats":null,"previous_names":["monkey-projects/deploy-inst"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monkey-projects%2Fdeploy-inst","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monkey-projects%2Fdeploy-inst/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monkey-projects%2Fdeploy-inst/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monkey-projects%2Fdeploy-inst/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monkey-projects","download_url":"https://codeload.github.com/monkey-projects/deploy-inst/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254535799,"owners_count":22087400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-16T13:11:52.886Z","updated_at":"2025-05-16T13:12:08.493Z","avatar_url":"https://github.com/monkey-projects.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OCI Deploy Instances\n\nThis is a Clojure lib intended to be used to redeploy applications running\nin container instances.  Currently there is no way to do this without\ndowntime: a running instance cannot be modified and there is no support\nto shift traffic from one instance to another without some manual\nintervention.  This library aims to provide functionality to allow easy\nupgrading of container instances.  Using it, you can specify which container\ninstance needs to be replaced and which backendsets are impacted.  It will\nautomatically create the new instance, create a backend for it and then\ndrain the old backend and shut down the old instance.\n\n## Why\n\nI created this lib because I wanted to be able to mimic the deployment\nfunctionality present in Kubernetes, without having to set up a full-blown\ncluster.  In OCI it's currently not possible to redeploy a container instance\nwithout downtime.  This library provides basic functionality to remedy that.\n\n## Usage\n\nAlthough you can include it in other code and invoke the [core namespace](src/monkey/oci/deploy/core.clj)\nfunctions directly, it's more meant to be called using the command line.  For\nthis, you need [Clojure CLI tools](https://clojure.org/reference/deps_and_cli).\n\nThe main function to invoke is `redeploy`, from the [cli namespace](src/monkey/oci/deploy/cli.clj).\nYou need to pass in the necessary configuration:\n\n - `config-file`: the file that holds OCI configuration, like credentials and tenancy ocid.\n - `ci-config` or `ci-config-file`: the configuration for the container instance.\n - `ci-filter`: a map that will be used to match any existing instances.\n - `lb-filter`: a map to find the load balancer for traffic routing.\n - `backends`: configuration for the backends.\n\nInclude it in your `deps.edn`:\n```clojure\n{:deps {com.monkeyprojects/deploy-inst {:mvn/version \"\u003cversion\u003e\"}}\n :aliases\n {:deploy\n  {:exec-fn monkey.oci.deploy.cli/redeploy}}}\n```\n\nYou can invoke it using `clj`:\n```bash\n$ clj -X:deploy\n```\nNote that you have to pass in any additional configuration on the command line, or\nspecify `:exec-args` in your `deps.edn` (recommended).\n\nThe configuration is loaded using [Aero](https://github.com/juxt/aero?tab=readme-ov-file),\nso all functions provided there are available here.  In addition there is a `#base64`\nreader literal, that reads a file and converts it to base64.  This way, you can set up\nconfigfile volumes in the instances.\n\n## How it works\n\nThe redeploy procedure is executed in several steps:\n\n 1. Create the new container instance, using the specified configuration.\n 2. Find the ip address for the existing instance.\n 3. Find existing backends for the ip addresses.  We'll need this to remove old routing later.\n 4. Create new backends for the new container instance, using the configured ports.\n 5. Wait for the backends to come online.\n 6. Drain and delete old backends.\n 7. Delete the old instance.\n\nAfter marking the existing backends as draining, we wait for 10 seconds before\nwe actually delete them.  If no matching container instance is found, nothing\nwill be deleted.\n\nNote that this lib expects the backendsets and load balancer to already be provisioned.\nIt will not create any of those, so if they don't exist, it will error out.\n\n## Examples\n\nAn example container instance config can look like this:\n```clojure\n{:display-name \"webserver\"\n :availability-domain \"GARu:EU-FRANKFURT-1-AD-3\"\n :compartment-id \"ocid1.compartment.oc1..aaaaaaaahxfsiiidq5pdesassc3pnnvozwd3fbi5raj6twjutodnfpinv6ba\"\n :shape \"CI.Standard.A1.Flex\"\n :shape-config {:ocpus 1\n                :memory-in-g-bs 1}\n :vnics\n [{:subnet-id \"ocid1.subnet.oc1.eu-frankfurt-1.aaaaaaaasbiuwybxsnmmg4weerznc32nmapcqtd2hbc24qgdkcusgg6b6a7a\"}]\n\n :containers\n [{:display-name \"apache\"\n   :image-url \"docker.io/httpd:2.4\"}]\n}\n```\nNote that you need to specify an availability domain, compartment id and subnet id to\nprovision the instance.\n\nA load balancer or container instance filter is just a map of properties that will\nbe matched exactly, like this:\n```clojure\n{:display-name \"webserver\"\n :lifecycle-state \"ACTIVE\"\n :freeform-tags {:env \"prod\"}}\n```\n\nBackend configuration is a list of maps that hold port and backend set names:\n```clojure\n[{:port 80\n  :backend-set \"http\"}]\n```\nThe backend set must already exist in the load balancer.\n\n## TODO\n\n - Create backendsets if not existing yet.\n - Roll back on failure.\n - Smarter error checking, like retry on a 429 instead of just failing.\n - Add functionality to just delete a container instance and backends without creating a new one.\n - Allow for \"dry running\"\n\n## License\n\nCopyright (c) 2024 by [Monkey Projects BV](https://www.monkey-projects.be)\n\n[MIT License](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonkey-projects%2Fdeploy-inst","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonkey-projects%2Fdeploy-inst","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonkey-projects%2Fdeploy-inst/lists"}