Last active
December 23, 2023 09:27
-
-
Save ChaitanyaChandra/c09d9aa222e3903b5870378303604b18 to your computer and use it in GitHub Desktop.
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
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: nginx-html | |
data: | |
index.html: | | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Hostname Display</title> | |
</head> | |
<body> | |
<h1>Hostname:</h1> | |
<p id="hostname"></p> | |
<script> | |
// Fetch and display hostname using JavaScript | |
fetch('/api/hostname') | |
.then(response => response.text()) | |
.then(data => { | |
document.getElementById('hostname').innerText = data; | |
}) | |
.catch(error => console.error('Error fetching hostname:', error)); | |
</script> | |
</body> | |
</html> | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: nginx-deployment | |
spec: | |
replicas: 2 | |
selector: | |
matchLabels: | |
app: nginx | |
template: | |
metadata: | |
labels: | |
app: nginx | |
spec: | |
containers: | |
- name: nginx | |
image: nginx:latest | |
ports: | |
- containerPort: 80 | |
volumeMounts: | |
- name: nginx-html | |
mountPath: /usr/share/nginx/html | |
readOnly: true | |
volumes: | |
- name: nginx-html | |
configMap: | |
name: nginx-html | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: nginx-service | |
spec: | |
selector: | |
app: nginx | |
ports: | |
- protocol: TCP | |
port: 80 | |
targetPort: 80 | |
type: LoadBalancer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment