Skip to content

Commit

Permalink
demo iteration 1
Browse files Browse the repository at this point in the history
  • Loading branch information
bhanvimenghani committed Aug 12, 2022
1 parent 9578817 commit c1a4d68
Show file tree
Hide file tree
Showing 40 changed files with 55,985 additions and 31,915 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Dependency directories
node_modules/

# Distribution directories
dist/
23 changes: 18 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

FROM node:14.17.0 AS builder
FROM node:16 AS builder

WORKDIR /builder

Expand All @@ -14,14 +14,27 @@ RUN npm run build

# Production image

FROM node:14.17.0
FROM registry.access.redhat.com/ubi8/nginx-118

COPY --from=builder /builder/dist ./dist
# WORKDIR /usr/share/nginx/html

RUN npm install -g serve
USER root

CMD ["serve", "-s", "dist"]
RUN rm -rf ./*

COPY --from=builder /builder/dist/* ./

USER default

WORKDIR /etc/nginx

RUN cp nginx.conf /tmp
RUN sed -i 's|listen \[::\]:8080 default_server|listen 8080|' /tmp/nginx.conf
RUN sed -i 's|listen 8080 default_server;||' /tmp/nginx.conf
RUN cat /tmp/nginx.conf >nginx.conf

# RUN cat nginx.conf

# ENTRYPOINT ["/bin/sh", "-c" ,"nginx -t && nginx -g daemon off;"]

ENTRYPOINT ["nginx", "-g", "daemon off;"]
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,27 @@ To run the kruize ui you can select any of the 2 options :
Latest Node.js source code can be downloaded from [here](https://nodejs.org/en/download/).
To run the Kruize-ui: clone the repository and then execute the following command to run the launch script.<br />
```
sh launch.sh
source deploy.sh
```
<br />

2. Containerized way<br />
We make use of nginx as a default react server for the UI.
Create the image using the following command<br />

```
docker build -t sample-kruize-ui -f Dockerfile .
docker build -t static-nginx .
```
Run the application using the following command

```
docker run --rm -it -p 9000:3000 sample-kruize-ui
docker run --rm -it -p 8080:8080 static-nginx
```
Use http://localhost:9000/ to view the UI in Browser.

here static-nginx is the image name.<br />
Use http://localhost:8080/ to view the UI in Browser.



## Code Origin
This repository uses the patternfly-react-seed base code as copied from [Patternfly Seed](https://github.com/patternfly/patternfly-react-seed).
79 changes: 79 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash

function start_gui() {
if rpm -qa | grep npm
then
npm run start:dev
else
echo "npm is NOT Installed on your machine."
fi
}
function check_cluster() {
cluster_type=$(kubectl config current-context | grep "minikube")
cluster_info=$(kubectl -n openshift cluster-info | grep -q "running")

if [ "${cluster_type}" == "minikube" ]; then
echo "Connected to minikube cluster" ;
call_cmds "minikube"


elif [ "$cluster_info" == "running" ]; then
echo "Connected to openshift cluster" ;
call_cmds "openshift"
else
echo "NO cluster connected"
fi
}

function call_cmds() {
CLUSTER=$1

get_ip $CLUSTER
get_port $CLUSTER
get_url $CLUSTER_IP $AUTOTUNE_PORT
display_url_output $url
export CLUSTER_IP=$CLUSTER_IP
export AUTOTUNE_PORT=$AUTOTUNE_PORT
start_gui
}

function get_ip() {
CLUSTER=$1
if [ "${CLUSTER}" == "minikube" ]; then
CLUSTER_IP=$( ${CLUSTER} ip)
elif [ "${CLUSTER}" == "openshift" ]; then
CLUSTER_IP=$(kubectl -n openshift-tuning get pods -l=app=autotune -o wide -n openshift-tuning -o=custom-columns=NODE:.spec.nodeName --no-headers)
fi
echo $CLUSTER_IP
}

function get_port() {
CLUSTER=$1
if [ "${CLUSTER}" == "minikube" ]; then
kubectl_cmd="kubectl -n monitoring"
elif [ "${CLUSTER}" == "openshift" ]; then
kubectl_cmd="kubectl -n openshift-tuning"
fi
AUTOTUNE_PORT=$(${kubectl_cmd} get svc autotune --no-headers -o=custom-columns=PORT:.spec.ports[*].nodePort)
echo $AUTOTUNE_PORT
}

function get_url() {
CLUSTER_IP=$1
AUTOTUNE_PORT=$2
url=http://${CLUSTER_IP}:${AUTOTUNE_PORT}/listAutotuneTunables
echo "Info: Access Autotune tunables at $url"
}

function display_url_output() {
url=$1

if (curl ${url}) then
echo "Autotune is up and running"
else
echo "Error: Autotune not running"
fi
echo $url
}

check_cluster
21 changes: 21 additions & 0 deletions env.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export function get_ip() {
if (process.env.CLUSTER_IP) {
const ip = process.env["CLUSTER_IP"];
console.debug("MINIKUBE IP is " + process.env["CLUSTER_IP"]);
return ip;
} else {
console.debug("No set!");
return null;
}
}
export function get_port() {
if (process.env.AUTOTUNE_PORT) {
const port = process.env["AUTOTUNE_PORT"];
console.debug("autotun is on! " + process.env["AUTOTUNE_PORT"]);
return port;
} else {
console.debug("No set!");
return null;
}
}

9 changes: 0 additions & 9 deletions launch.sh

This file was deleted.

Loading

0 comments on commit c1a4d68

Please sign in to comment.