forked from docker/genai-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from abdulrahman305/aks-devhub-vznfc
Add workflow to deploy to AKS
- Loading branch information
Showing
5 changed files
with
118 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,2 @@ | ||
* | ||
!*.py | ||
!requirements.txt | ||
!images/* | ||
!front-end/* | ||
front-end/node_modules/* | ||
Dockerfile | ||
charts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: genstack | ||
"on": | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: {} | ||
env: | ||
ACR_RESOURCE_GROUP: kubeops_group | ||
AZURE_CONTAINER_REGISTRY: acrworkflow1723012492625 | ||
CLUSTER_NAME: kube | ||
CLUSTER_RESOURCE_GROUP: kubeops_group | ||
CONTAINER_NAME: image-workflow-1723012492625 | ||
DEPLOYMENT_MANIFEST_PATH: | | ||
manifests/deployment.yaml | ||
manifests/service.yaml | ||
jobs: | ||
buildImage: | ||
permissions: | ||
contents: read | ||
id-token: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 | ||
name: Azure login | ||
with: | ||
client-id: ${{ secrets.AZURE_CLIENT_ID }} | ||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
- name: Build and push image to ACR | ||
run: az acr build --image ${{ env.CONTAINER_NAME }}:${{ github.sha }} --registry ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.ACR_RESOURCE_GROUP }} -f Dockerfile ./ | ||
deploy: | ||
permissions: | ||
actions: read | ||
contents: read | ||
id-token: write | ||
runs-on: ubuntu-latest | ||
needs: | ||
- buildImage | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 | ||
name: Azure login | ||
with: | ||
client-id: ${{ secrets.AZURE_CLIENT_ID }} | ||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
- uses: azure/use-kubelogin@v1 | ||
name: Set up kubelogin for non-interactive login | ||
with: | ||
kubelogin-version: v0.0.25 | ||
- uses: azure/aks-set-context@v3 | ||
name: Get K8s context | ||
with: | ||
admin: "false" | ||
cluster-name: ${{ env.CLUSTER_NAME }} | ||
resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }} | ||
use-kubelogin: "true" | ||
- uses: Azure/k8s-deploy@v4 | ||
name: Deploys application | ||
with: | ||
action: deploy | ||
images: ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }} | ||
manifests: ${{ env.DEPLOYMENT_MANIFEST_PATH }} | ||
namespace: aks-istio-system |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM python:3.11-slim | ||
ENV PORT 8000 | ||
EXPOSE 8000 | ||
WORKDIR /usr/src/app | ||
|
||
COPY requirements.txt ./ | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
COPY . . | ||
|
||
ENTRYPOINT ["python"] | ||
CMD ["app.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: genstack | ||
labels: | ||
app: genstack | ||
kubernetes.azure.com/generator: devhub | ||
namespace: aks-istio-system | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: genstack | ||
template: | ||
metadata: | ||
labels: | ||
app: genstack | ||
spec: | ||
containers: | ||
- name: genstack | ||
image: acrworkflow1723012492625.azurecr.io/image-workflow-1723012492625:latest | ||
imagePullPolicy: Always | ||
ports: | ||
- containerPort: 8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: genstack | ||
namespace: aks-istio-system | ||
labels: | ||
kubernetes.azure.com/generator: devhub | ||
spec: | ||
type: LoadBalancer | ||
selector: | ||
app: genstack | ||
ports: | ||
- protocol: TCP | ||
port: 8000 | ||
targetPort: 8000 |