{"id":24941605,"url":"https://github.com/inforian/django-kubernetes-azure","last_synced_at":"2025-04-10T03:04:57.807Z","repository":{"id":46631857,"uuid":"92580432","full_name":"inforian/django-kubernetes-azure","owner":"inforian","description":"Django project Deployment on Azure Container Machine using Kubernetes as orchestration Tool","archived":false,"fork":false,"pushed_at":"2021-10-02T20:30:15.000Z","size":20,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T04:35:15.826Z","etag":null,"topics":["azure","django","docker","docker-image","kubernetes"],"latest_commit_sha":null,"homepage":null,"language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inforian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-27T07:30:53.000Z","updated_at":"2020-06-20T18:15:14.000Z","dependencies_parsed_at":"2022-08-31T10:30:23.618Z","dependency_job_id":null,"html_url":"https://github.com/inforian/django-kubernetes-azure","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inforian%2Fdjango-kubernetes-azure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inforian%2Fdjango-kubernetes-azure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inforian%2Fdjango-kubernetes-azure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inforian%2Fdjango-kubernetes-azure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inforian","download_url":"https://codeload.github.com/inforian/django-kubernetes-azure/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248148228,"owners_count":21055547,"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":["azure","django","docker","docker-image","kubernetes"],"created_at":"2025-02-02T18:23:36.809Z","updated_at":"2025-04-10T03:04:57.756Z","avatar_url":"https://github.com/inforian.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# django-kubernetes-azure\nDjango project Deployment on Azure Container Machine using Kubernetes as orchestration Tool.\n\n### Preliminary steps\n\n- Clone this repo source code :\n\n```\nhttps://github.com/inforian/django-kubernetes-azure.git\n```\n \n- Run python manage.py runserver , and visit Browser you will see pink theme Template.\n\n### Publish Docker Containers\n\n- Install [Docker](https://docs.docker.com/engine/installation/)\n\n\n- Build docker image for pink theme :\n \n```docker\ndocker build -t dj:pink . ## (assuming you are inside django project)\n```\n  \n- Now , Build Image for Orange theme BUt before that edit template index.html\n  and copy paste below code inside `\u003chead\u003e` tag.\n```html\n\u003cstyle\u003e\n    #banner {\n        background-color: #ffa500;\n    }\n\u003c/style\u003e\n```\n  \n- Refresh Django dev server url you will see ornage theme.\n- Build image for Orange theme\n```docker\ndocker build -t dj:orange .\n```\n  \n- Check your iamges : \n```docker\ndocker images | grep dj \n```\n  \n - Now Login to you docker hub Account and push this image to docker-hub: \n ```docker\n    docker login\n    \n    # for orange\n     docker tag {image_id} {docker_hub_username}/dj:orange\n    \n    # for pink\n     docker tag {image_id} {docker_hub_username}/dj:pink\n```\n \n### Azure\n - Create a Resource on Azure, You have to choose Azure Container service from Azure portal from their\n  you can choose any `kubernetes` as orchestration type.\n  \n![containers microsoft azure](https://cloud.githubusercontent.com/assets/15274390/26521350/41e9c5d4-4304-11e7-8a3d-96eb88e20a47.png)\n  \n - After your Machine is up and Running connect with you `Master VM` via `SSh` \n \n![master_k8s](https://cloud.githubusercontent.com/assets/2461556/26521392/258f73a6-4305-11e7-915c-9844f7f8b8c9.png)\n\n- Copy files from `kubernetes_config` to `Master VM` \n\n- You must have 3 files on `Master VM`\n    - rc-orange.yaml\n    - rc-pink.yaml\n    - service.yaml\n\n### Kubernetes\n\n- Create replication controller for pink theme (I have created only one rc so only one pod will be created): \n```\nkubectl create -f rc-pink.yaml\n```\n-  \n\n- Create service with :\n```\n kubectl create -f service.yaml \n```\n\n- List your service to check status (Wait for some time till external ip assigned to your service) : \n\n```\nkubectl get service | grep my-dj-app\n```\n\n- If external ip is assigned to your service then visit app url which will be like:\n```\nhttp://{external-ip}:8000  # you will see pink theme\n```\n\n### Play with Kubernetes and see its Magic :\n\n- Now create replication controller for orange theme, I have created 3 `Rc's` here :\n```\nkubectl create -f rc-orange.yaml\n```\n\n- Check newly created `RC` and wait for it un-till it is ready with : \n```\n kubectl get rc | grep dj-orange\n```\n\n- Note : No new service will be craeted here but we have bind orange-theme `RC`\nwith already existing Service (which craeted above).\n\n- Refresh web url(refresh it every other second by pressing f5) , you will see web theme is switching \nfrom pink to orange and vice-versa on every refresh or some time remain as it was before.\n\n- Now we will Scale down pink theme replica to `0` , visit web url now only orange theme will work \n```\nkubectl scale rc/dj-pink --replicas=0\n```\n\n- Scale up Pink theme `RC` again to `1` and - orange to `0` \n```\nkubectl scale rc/dj-pink --replicas=1\n\nkubectl scale rc/dj-orange --replicas=0\n```\n- Now only pink theme will work, this way you can easily roll out \nyour new version of site, or we you want to scale you `RC's` according to traffic \non your sites's , you can scale them using above commands.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finforian%2Fdjango-kubernetes-azure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finforian%2Fdjango-kubernetes-azure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finforian%2Fdjango-kubernetes-azure/lists"}