From e22651eb3a8b88f6334d4e1a297752ae4d82228c Mon Sep 17 00:00:00 2001 From: Shakil Date: Wed, 28 May 2025 18:12:56 +0530 Subject: [PATCH 1/4] Adding steps by steps guide for manual EKS and Bastion setup --- session-iac/infra/manual_setup.md | 264 +++++++++++++++++++++++++++++ session-iac/infra/manual_setup.txt | 16 ++ 2 files changed, 280 insertions(+) create mode 100755 session-iac/infra/manual_setup.md diff --git a/session-iac/infra/manual_setup.md b/session-iac/infra/manual_setup.md new file mode 100755 index 0000000..768e873 --- /dev/null +++ b/session-iac/infra/manual_setup.md @@ -0,0 +1,264 @@ +# Setting up EKS Access from EC2 Bastion Host + +This guide walks through setting up Amazon EKS cluster And accessing from an EC2 bastion host, including VPC configuration, IAM roles, and kubectl setup. + +## Prerequisites + +- AWS Account with appropriate permissions +- Basic understanding of VPC, IAM, and EKS concepts +- AWS CLI configured (optional but recommended) + +## Architecture Overview + +This setup creates: +- A VPC with public and private subnets +- An EKS cluster in private subnets +- A bastion host in public subnet for secure access +- Proper IAM roles and security group configurations + +## Step-by-Step Implementation + +### Step 1: Create VPC + +Create a VPC where you want to deploy your EKS cluster. + +**Requirements:** +- Public subnets for bastion host and NAT gateway +- Private subnets for EKS worker nodes +- Internet Gateway and NAT Gateway for connectivity + +![image](https://github.com/user-attachments/assets/a67677a6-f94f-4f7c-bb35-b1a8e50f5c95) + + +### Step 2: Create EKS Service Role + +Create an IAM role that allows the EKS control plane to manage AWS resources on your behalf. + +1. Go to **IAM Console** → **Roles** → **Create role** +2. Select **AWS Service** → **EKS** → **EKS - Cluster** +3. Attach the following managed policies: + - `AmazonEKSClusterPolicy` +4. Name the role (e.g., `eks-cluster-role`) +5. Create the role +![image](https://github.com/user-attachments/assets/958e3fba-286b-42c3-a415-43870153646c) + +![image](https://github.com/user-attachments/assets/58585460-74b6-411b-993f-24ea7fb8167a) + +Change role name as you created +![image](https://github.com/user-attachments/assets/d3db951d-85c1-44c0-8570-23eeb90c9dd8) + +### Step 3: Create EKS Cluster + +1. Navigate to **EKS Console** → **Create cluster** +2. **Cluster Configuration:** + - Name: `my-eks` (or your preferred name) + - Kubernetes version: Latest stable + - Service role: Select the role created in Step 2 + +3. **Networking:** + - VPC: Select your VPC from Step 1 + - Subnets: Choose **private subnets** only + - Security groups: Default EKS security group + - Endpoint access: + - Public access: Enabled + - Private access: Enabled + - Description: "The cluster endpoint is accessible from outside of your VPC. Worker node traffic to the endpoint will stay within your VPC." + +4. **Access Configuration:** + - Authentication mode: API and ConfigMap + - Allow cluster administrator access for your IAM principal + +5. Click **Next** → **Next** → **Create** + +6. **Copy the cluster ARN** for later use: + ``` + arn:aws:eks:ap-south-1:267714372222:cluster/my-eks + ``` +![image](https://github.com/user-attachments/assets/00069cd9-f196-4f2f-a80c-b3ed71e49c61) + +![image](https://github.com/user-attachments/assets/10760474-8444-447c-86fd-16e6c06bf634) + +![image](https://github.com/user-attachments/assets/af41b4cb-afc1-4570-a9b1-b5de7acd478e) + + +### Step 4: Create IAM Role for Bastion Host + +Create an IAM role for the EC2 bastion host to access EKS cluster. + +1. Go to **IAM Console** → **Roles** → **Create role** +2. Select **AWS Service** → **EC2** +3. Attach the following managed policies: + - `AmazonEKSClusterPolicy` + - and create a custom policy with EKS Describe Policy + +4. Name the role: `bastion-eks-access-role` +5. Create the role + +![image](https://github.com/user-attachments/assets/7a6ca4a2-8e54-41a2-93a8-99b2ee858e37) + +![image](https://github.com/user-attachments/assets/bd957692-669b-41fe-bbda-1b6b91998bbc) + +![image](https://github.com/user-attachments/assets/36a0c02b-cd52-4697-86ff-375ca2219ee9) + + +### Step 5: Launch Bastion Host + +1. Go to **EC2 Console** → **Launch Instance** +2. **Configuration:** + - AMI: Amazon Linux 2 or Ubuntu + - Instance type: t3.micro (or as needed) + - VPC: Same VPC as EKS cluster + - Subnet: **Public subnet** + - Auto-assign public IP: **Enable** + - Security group: Allow SSH (port 22) from your IP + - IAM role: `bastion-eks-access-role` + +3. Launch the instance + +![image](https://github.com/user-attachments/assets/dc05270c-43e3-4168-a2c2-c328b84d324b) + +![image](https://github.com/user-attachments/assets/2e5b7f0e-b5a6-48a6-9bd2-6a228ed04dbe) + + +### Step 6: Install kubectl on Bastion Host + +SSH into your bastion host and install kubectl: + +```bash +# Download kubectl +curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" + +# Make it executable +chmod +x kubectl + +# Move to system path +sudo mv kubectl /usr/local/bin/ + +# Verify installation +kubectl version --client +``` +![image](https://github.com/user-attachments/assets/a34c1621-34ee-4504-aafb-09b596a26481) + +*Initial connection will fail - this is expected and will be resolved in the following steps.* + +### Step 7: Configure EKS Security Group + +Allow the bastion host to communicate with the EKS cluster by updating the EKS security group. + +1. Go to **EC2 Console** → **Security Groups** +2. Find the EKS cluster security group +3. **Add Inbound Rule:** + - Type: All traffic (or specific ports as needed) + - Source: VPC CIDR block (e.g., 10.0.0.0/16) + +![image](https://github.com/user-attachments/assets/f6650066-0e93-4741-934f-3a0d6adc9e68) + +![image](https://github.com/user-attachments/assets/54abe22c-0d9b-488c-994a-78d041d235c2) + +![image](https://github.com/user-attachments/assets/19ef5e39-8453-4967-a0c7-37c835cab64d) + + +### Step 8: Update AWS Auth ConfigMap + +⚠️ **Important:** This step must be performed from your AWS account that created the EKS cluster (use CloudShell or local AWS CLI). + +1. **Create the aws-auth ConfigMap YAML file if not present:** + +```yaml +# aws-auth.yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: aws-auth + namespace: kube-system +data: + mapRoles: | + - rolearn: arn:aws:iam::267714372222:role/bastion-eks-access-role + groups: + - system:masters +``` + +2. **Apply the ConfigMap:** + +```bash +# First, configure kubectl to connect to your EKS cluster +aws eks update-kubeconfig --region ap-south-1 --name my-eks + +# Apply the aws-auth ConfigMap +kubectl apply -f auth-aws.yaml +``` + +![image](https://github.com/user-attachments/assets/ac1ef1dc-aee0-4733-98ab-fc668c31c64d) + + +### Step 9: Configure kubectl on Bastion Host + +On the bastion host, configure kubectl to connect to your EKS cluster: + +```bash +# Configure kubectl +aws eks update-kubeconfig --region ap-south-1 --name my-eks + +# Test the connection +kubectl get nodes +kubectl get pods --all-namespaces +``` + +![image](https://github.com/user-attachments/assets/dc9a1be9-87b8-4e04-b04c-852576aac3dc) + + +## Verification + +After completing all steps, you should be able to: + +1. SSH into the bastion host +2. Run `kubectl` commands successfully +3. View cluster nodes and pods +4. Deploy applications to the EKS cluster + +## Troubleshooting + +### Common Issues: + +1. **"error: You must be logged in to the server (Unauthorized)"** + - Verify the aws-auth ConfigMap is correctly applied + - Ensure the bastion host IAM role ARN matches in the ConfigMap + +2. **Connection timeout** + - Check EKS security group allows traffic from VPC CIDR + - Verify bastion host is in public subnet with internet access + +3. **kubectl command not found** + - Reinstall kubectl following Step 6 + +## Security Considerations + +- Bastion host should only allow SSH from trusted IP addresses +- Use session manager instead of SSH for enhanced security +- Regularly rotate IAM credentials +- Monitor bastion host access logs +- Consider using AWS Systems Manager Session Manager + +## Clean Up + +To avoid charges, remember to delete: +1. EKS cluster +2. EC2 bastion host +3. NAT Gateway +4. Elastic IPs +5. VPC (if no longer needed) + +## References + +- [Amazon EKS User Guide](https://docs.aws.amazon.com/eks/latest/userguide/) +- [Managing users or IAM roles for your cluster](https://docs.aws.amazon.com/eks/latest/userguide/add-user-role.html) +- [kubectl installation guide](https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/) + +--- + +**Note:** Replace account IDs, region names, and resource ARNs with your actual values. + + + + + diff --git a/session-iac/infra/manual_setup.txt b/session-iac/infra/manual_setup.txt index 719db6e..4e0c011 100644 --- a/session-iac/infra/manual_setup.txt +++ b/session-iac/infra/manual_setup.txt @@ -30,6 +30,22 @@ mapRoles: | groups: - system:masters +Note: If the ConfigMap is not created by default, please create it manually. + +#cat auth-aws.yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: aws-auth + namespace: kube-system +data: + mapRoles: | + - rolearn: arn:aws:iam::267714372222:role/bastion-eks-access-role + groups: + - system:masters + +#kubectl apply -f auth-aws.yaml + ### In the EKS SG add inbound traffic for VPC CIDR ### Now ssh into bastion, install and configure kubectl From 0faa95a3ede373054b5be5e900d602c604f54699 Mon Sep 17 00:00:00 2001 From: linuxshakil Date: Wed, 28 May 2025 18:20:20 +0530 Subject: [PATCH 2/4] Update manual_setup.md --- session-iac/infra/manual_setup.md | 50 +++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/session-iac/infra/manual_setup.md b/session-iac/infra/manual_setup.md index 768e873..2902335 100755 --- a/session-iac/infra/manual_setup.md +++ b/session-iac/infra/manual_setup.md @@ -27,7 +27,8 @@ Create a VPC where you want to deploy your EKS cluster. - Private subnets for EKS worker nodes - Internet Gateway and NAT Gateway for connectivity -![image](https://github.com/user-attachments/assets/a67677a6-f94f-4f7c-bb35-b1a8e50f5c95) +![image](https://github.com/user-attachments/assets/3e992773-2cc2-4e12-9d1c-4ac9e6d13b31) + ### Step 2: Create EKS Service Role @@ -40,9 +41,11 @@ Create an IAM role that allows the EKS control plane to manage AWS resources on - `AmazonEKSClusterPolicy` 4. Name the role (e.g., `eks-cluster-role`) 5. Create the role -![image](https://github.com/user-attachments/assets/958e3fba-286b-42c3-a415-43870153646c) +![image](https://github.com/user-attachments/assets/6ce5aa96-3053-43c3-a319-199f613d8873) + + +![image](https://github.com/user-attachments/assets/df0737c4-7ba5-408f-9469-6e9e674dcb0c) -![image](https://github.com/user-attachments/assets/58585460-74b6-411b-993f-24ea7fb8167a) Change role name as you created ![image](https://github.com/user-attachments/assets/d3db951d-85c1-44c0-8570-23eeb90c9dd8) @@ -74,11 +77,15 @@ Change role name as you created ``` arn:aws:eks:ap-south-1:267714372222:cluster/my-eks ``` -![image](https://github.com/user-attachments/assets/00069cd9-f196-4f2f-a80c-b3ed71e49c61) +![image](https://github.com/user-attachments/assets/ece54ab2-81d7-4b3d-a7e1-fb0d7a603eb2) + -![image](https://github.com/user-attachments/assets/10760474-8444-447c-86fd-16e6c06bf634) +![image](https://github.com/user-attachments/assets/29562dd5-3cd7-4b6b-bdf3-c0d3f9977ef1) -![image](https://github.com/user-attachments/assets/af41b4cb-afc1-4570-a9b1-b5de7acd478e) + +![image](https://github.com/user-attachments/assets/0650b995-7749-4378-a75f-424049496d07) + +![image](https://github.com/user-attachments/assets/30174503-1a67-4a01-ac19-b421e10e722f) ### Step 4: Create IAM Role for Bastion Host @@ -94,11 +101,14 @@ Create an IAM role for the EC2 bastion host to access EKS cluster. 4. Name the role: `bastion-eks-access-role` 5. Create the role -![image](https://github.com/user-attachments/assets/7a6ca4a2-8e54-41a2-93a8-99b2ee858e37) +![image](https://github.com/user-attachments/assets/2c9e7a48-0862-4278-97a8-a61f8d19f3bb) + + +![image](https://github.com/user-attachments/assets/b8452c2a-0cbe-4ec6-aa2d-f63a00bdda4f) -![image](https://github.com/user-attachments/assets/bd957692-669b-41fe-bbda-1b6b91998bbc) -![image](https://github.com/user-attachments/assets/36a0c02b-cd52-4697-86ff-375ca2219ee9) +![image](https://github.com/user-attachments/assets/56ecb74c-0e6a-46b1-acf5-9566ed8abe83) + ### Step 5: Launch Bastion Host @@ -115,9 +125,11 @@ Create an IAM role for the EC2 bastion host to access EKS cluster. 3. Launch the instance -![image](https://github.com/user-attachments/assets/dc05270c-43e3-4168-a2c2-c328b84d324b) +![image](https://github.com/user-attachments/assets/4e12e1e2-297e-4f46-80fa-7657b46ccd28) + + +![image](https://github.com/user-attachments/assets/144d4c5f-d30b-4bd2-9f80-1ee1b3a6f9b2) -![image](https://github.com/user-attachments/assets/2e5b7f0e-b5a6-48a6-9bd2-6a228ed04dbe) ### Step 6: Install kubectl on Bastion Host @@ -137,7 +149,8 @@ sudo mv kubectl /usr/local/bin/ # Verify installation kubectl version --client ``` -![image](https://github.com/user-attachments/assets/a34c1621-34ee-4504-aafb-09b596a26481) +![image](https://github.com/user-attachments/assets/11c9063b-426a-49af-95cd-a6274c193a39) + *Initial connection will fail - this is expected and will be resolved in the following steps.* @@ -151,11 +164,14 @@ Allow the bastion host to communicate with the EKS cluster by updating the EKS s - Type: All traffic (or specific ports as needed) - Source: VPC CIDR block (e.g., 10.0.0.0/16) -![image](https://github.com/user-attachments/assets/f6650066-0e93-4741-934f-3a0d6adc9e68) +![image](https://github.com/user-attachments/assets/91f8b7e2-7907-4aac-8b00-db1d7874461d) -![image](https://github.com/user-attachments/assets/54abe22c-0d9b-488c-994a-78d041d235c2) -![image](https://github.com/user-attachments/assets/19ef5e39-8453-4967-a0c7-37c835cab64d) +![image](https://github.com/user-attachments/assets/5a2b8e8f-e32b-4ad6-8ff3-9327c536bad8) + + +![image](https://github.com/user-attachments/assets/f1da370d-0ee0-4fb7-bbb7-cc85329bcc92) + ### Step 8: Update AWS Auth ConfigMap @@ -187,6 +203,7 @@ aws eks update-kubeconfig --region ap-south-1 --name my-eks # Apply the aws-auth ConfigMap kubectl apply -f auth-aws.yaml ``` +![image](https://github.com/user-attachments/assets/c4ba0740-cf4b-4d9a-ba87-999e9912d9dc) ![image](https://github.com/user-attachments/assets/ac1ef1dc-aee0-4733-98ab-fc668c31c64d) @@ -204,7 +221,8 @@ kubectl get nodes kubectl get pods --all-namespaces ``` -![image](https://github.com/user-attachments/assets/dc9a1be9-87b8-4e04-b04c-852576aac3dc) +![image](https://github.com/user-attachments/assets/200059eb-af39-41f3-91f2-0b60aae7b18c) + ## Verification From 9b9cfdc9d423fece2eaec7f4936825bd34b670e6 Mon Sep 17 00:00:00 2001 From: linuxshakil Date: Wed, 28 May 2025 18:21:27 +0530 Subject: [PATCH 3/4] Update manual_setup.md --- session-iac/infra/manual_setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/session-iac/infra/manual_setup.md b/session-iac/infra/manual_setup.md index 2902335..4fb528e 100755 --- a/session-iac/infra/manual_setup.md +++ b/session-iac/infra/manual_setup.md @@ -1,4 +1,4 @@ -# Setting up EKS Access from EC2 Bastion Host +# Setting up EKS and Accessing from EC2 Bastion Host This guide walks through setting up Amazon EKS cluster And accessing from an EC2 bastion host, including VPC configuration, IAM roles, and kubectl setup. From 5312ce0ea93c984e02c1bd6c924daa9dc426e843 Mon Sep 17 00:00:00 2001 From: Shakil Date: Sat, 21 Jun 2025 08:25:04 +0530 Subject: [PATCH 4/4] fix: properly configure UI and backend using secrets and config maps --- session-7/calculator/app.py | 9 +++++++- session-7/deployment_yamls/app-configmap.yaml | 7 ++++++ session-7/deployment_yamls/app.yaml | 23 ++++++++++++++++++- session-7/deployment_yamls/db-secrets.yaml | 9 ++++++++ session-7/deployment_yamls/dbase.yaml | 12 +++++++--- session-7/deployment_yamls/ui-config.yaml | 6 +++++ session-7/deployment_yamls/ui.yaml | 9 +++++++- session-7/ui/Dockerfile | 16 +++++++++---- session-7/ui/calculator.js | 4 ++-- session-7/ui/entrypoint.sh | 8 +++++++ 10 files changed, 90 insertions(+), 13 deletions(-) create mode 100644 session-7/deployment_yamls/app-configmap.yaml create mode 100644 session-7/deployment_yamls/db-secrets.yaml create mode 100644 session-7/deployment_yamls/ui-config.yaml create mode 100644 session-7/ui/entrypoint.sh diff --git a/session-7/calculator/app.py b/session-7/calculator/app.py index 157ee0e..5296e49 100644 --- a/session-7/calculator/app.py +++ b/session-7/calculator/app.py @@ -6,6 +6,7 @@ from prometheus_client import Summary, Counter, Histogram, Gauge import time from flask_cors import CORS +import os #app = Flask(__name__) #mongo = MongoClient('database', 27017) @@ -14,7 +15,13 @@ app = Flask(__name__) -app.config["MONGO_URI"] = "mongodb://root:root@mongo-service.default.svc.cluster.local:27017/admin" +mongo_user = os.getenv('MONGO_USER') +mongo_pass = os.getenv('MONGO_PASS') +mongo_host = os.getenv('MONGO_HOST') +mongo_port = os.getenv('MONGO_PORT') + +mongo_uri = f"mongodb://{mongo_user}:{mongo_pass}@{mongo_host}:{mongo_port}/admin" +app.config["MONGO_URI"] = mongo_uri mongo = PyMongo(app) hits_collection = mongo.db.usage diff --git a/session-7/deployment_yamls/app-configmap.yaml b/session-7/deployment_yamls/app-configmap.yaml new file mode 100644 index 0000000..fbe9e00 --- /dev/null +++ b/session-7/deployment_yamls/app-configmap.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: mongo-config +data: + MONGO_HOST: "mongo-service.default.svc.cluster.local" + MONGO_PORT: "27017" diff --git a/session-7/deployment_yamls/app.yaml b/session-7/deployment_yamls/app.yaml index f2f7996..8fc6e6b 100644 --- a/session-7/deployment_yamls/app.yaml +++ b/session-7/deployment_yamls/app.yaml @@ -15,9 +15,30 @@ spec: serviceAccountName: mongo-admin containers: - name: calculator-app - image: syednadeembe/myflaskapp:productionImage_app + image: linuxshakil/myflaskapp:productionImage_app-v1 ports: - containerPort: 9000 + env: + - name: MONGO_HOST + valueFrom: + configMapKeyRef: + name: mongo-config + key: MONGO_HOST + - name: MONGO_PORT + valueFrom: + configMapKeyRef: + name: mongo-config + key: MONGO_PORT + - name: MONGO_USER + valueFrom: + secretKeyRef: + name: db-secrets + key: MONGO_USER + - name: MONGO_PASS + valueFrom: + secretKeyRef: + name: db-secrets + key: MONGO_PASS --- apiVersion: v1 kind: Service diff --git a/session-7/deployment_yamls/db-secrets.yaml b/session-7/deployment_yamls/db-secrets.yaml new file mode 100644 index 0000000..2963c52 --- /dev/null +++ b/session-7/deployment_yamls/db-secrets.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Secret +metadata: + name: db-secrets +type: Opaque +data: + MONGO_USER: cm9vdA== + MONGO_PASS: cm9vdA== + diff --git a/session-7/deployment_yamls/dbase.yaml b/session-7/deployment_yamls/dbase.yaml index e3a0569..a7e084a 100644 --- a/session-7/deployment_yamls/dbase.yaml +++ b/session-7/deployment_yamls/dbase.yaml @@ -15,14 +15,20 @@ spec: serviceAccountName: mongo-admin containers: - name: mongodb - image: mongo:latest + image: mongo:4.4 ports: - containerPort: 27017 env: - name: MONGO_INITDB_ROOT_USERNAME - value: root + valueFrom: + secretKeyRef: + name: db-secrets + key: MONGO_USER - name: MONGO_INITDB_ROOT_PASSWORD - value: root + valueFrom: + secretKeyRef: + name: db-secrets + key: MONGO_PASS --- apiVersion: v1 kind: Service diff --git a/session-7/deployment_yamls/ui-config.yaml b/session-7/deployment_yamls/ui-config.yaml new file mode 100644 index 0000000..d42d855 --- /dev/null +++ b/session-7/deployment_yamls/ui-config.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: ui-config +data: + BASE_URL: "http://192.168.1.103:30080" diff --git a/session-7/deployment_yamls/ui.yaml b/session-7/deployment_yamls/ui.yaml index c584b6c..6f876b2 100644 --- a/session-7/deployment_yamls/ui.yaml +++ b/session-7/deployment_yamls/ui.yaml @@ -14,9 +14,16 @@ spec: spec: containers: - name: ui - image: syednadeembe/myflaskapp:productionImage_ui + image: linuxshakil/myflaskapp:productionImage_ui-v1 ports: - containerPort: 80 + env: + - name: BASE_URL + valueFrom: + configMapKeyRef: + name: ui-config + key: BASE_URL + --- apiVersion: v1 kind: Service diff --git a/session-7/ui/Dockerfile b/session-7/ui/Dockerfile index 5f8d399..fe736de 100644 --- a/session-7/ui/Dockerfile +++ b/session-7/ui/Dockerfile @@ -1,9 +1,15 @@ -# Use a lightweight HTTP server image as the base FROM nginx:alpine -# Copy the HTML and JavaScript files to the default Nginx public directory -COPY index.html /usr/share/nginx/html -COPY calculator.js /usr/share/nginx/html +# Install envsubst +RUN apk add --no-cache gettext + +# Copy your HTML and JS as-is +COPY index.html /usr/share/nginx/html/ +COPY calculator.js /usr/share/nginx/html/ +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh -# Expose port 80 EXPOSE 80 + +CMD ["/entrypoint.sh"] diff --git a/session-7/ui/calculator.js b/session-7/ui/calculator.js index 04e4b16..b2653b8 100644 --- a/session-7/ui/calculator.js +++ b/session-7/ui/calculator.js @@ -1,5 +1,5 @@ // Configure the base URL for the backend services -const baseUrl = "http://localhost:30080"; // Use the actual service name and port +const baseUrl = "${BASE_URL}"; // Function to update and display website hits @@ -41,4 +41,4 @@ document.getElementById("multiplyBtn").addEventListener("click", () => calculate document.getElementById("divideBtn").addEventListener("click", () => calculate("divide")); // Initial update and display of website hits -updateHits(); \ No newline at end of file +updateHits(); diff --git a/session-7/ui/entrypoint.sh b/session-7/ui/entrypoint.sh new file mode 100644 index 0000000..83b4386 --- /dev/null +++ b/session-7/ui/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# Replace ${BASE_URL} in-place in calculator.js +envsubst '${BASE_URL}' < /usr/share/nginx/html/calculator.js > /usr/share/nginx/html/calculator.tmp.js && \ +mv /usr/share/nginx/html/calculator.tmp.js /usr/share/nginx/html/calculator.js + +# Start Nginx +nginx -g 'daemon off;'