diff --git a/GettingStarted.ipynb b/GettingStarted.ipynb index 5e3efb3..4333bb4 100644 --- a/GettingStarted.ipynb +++ b/GettingStarted.ipynb @@ -133,48 +133,49 @@ "hpecp k8scluster list " ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### `Do not continue if you dont get any output from the command above`" + ] + }, { "cell_type": "markdown", "metadata": {}, "source": [ " ### 2b.) Create kube_admin_config\n", - " Execute the following command to create the Kubernetes Admin configs for all clusters managed by HPECP" + " Execute the following command to create the Kubernetes Cluster Configuration\n" ] }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 31, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Clustername detected: development\n" + ] + } + ], "source": [ - "mkdir -p /home/${NB_USER}/data/k8sconfig/\n", - "CLUSTERS=$(hpecp k8scluster list --columns [id,name] --output text | sed 1d | tr -s '[:blank:]' ',')\n", - "for CLUSTER in $CLUSTERS;\n", - "do\n", - " ID=$(echo $CLUSTER | cut -d ',' -f 1)\n", - " NAME=$(echo $CLUSTER | cut -d ',' -f 2)\n", - " hpecp k8scluster admin-kube-config $ID > /home/${NB_USER}/data/k8sconfig/${NAME}_kube.conf\n", - "done\n", - "unset KUBECONFIG\n", - "for i in $(find /home/${NB_USER}/data/k8sconfig/*_kube.conf -maxdepth 0 -type f)\n", - "do\n", - " export KUBECONFIG=$KUBECONFIG:${i}\n", - " done\n", - "\n", - "\n" + "/home/hpecp/data/hpecp-tutorialbox-demo/tools/k8s-discovery.sh" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - " ### 2c.) Check if you are able to connect to the Kubernetes Cluster using the kubectl cli \n", - " You should receive the node list for your kubernetes cluster" + " ### 2c.) Check if you are able to list and access the Kubernetes Cluster using the kubectl cli \n", + "#### List your kubernetes Cluster" ] }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 32, "metadata": {}, "outputs": [ { @@ -182,7 +183,7 @@ "output_type": "stream", "text": [ "NAME\n", - "k8s-3\n" + "development\n" ] } ], @@ -190,27 +191,105 @@ "kubectl config get-clusters" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Select a kubernetes Cluster" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Switched to context \"development\".\n" + ] + } + ], + "source": [ + "kubectx development" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### List the Namespaces in your Cluster" + ] + }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 36, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "NAME STATUS ROLES AGE VERSION\n", - "ip-10-1-0-122.eu-west-3.compute.internal Ready worker 60d v1.17.0\n", - "ip-10-1-0-154.eu-west-3.compute.internal Ready worker 60d v1.17.0\n", - "ip-10-1-0-16.eu-west-3.compute.internal Ready master 68d v1.17.0\n", - "ip-10-1-0-254.eu-west-3.compute.internal Ready worker 60d v1.17.0\n", - "ip-10-1-0-56.eu-west-3.compute.internal Ready worker 68d v1.17.0\n", - "ip-10-1-0-64.eu-west-3.compute.internal Ready worker 68d v1.17.0\n" + "NAME STATUS AGE\n", + "default Active 69d\n" ] } ], "source": [ - "kubectl get nodes" + "kubectl get ns default" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Select a Namespace\n", + "The tool kubens can be used to easily switch between namespace/tenants" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Context \"development\" modified.\n", + "Active namespace is \"default\".\n" + ] + } + ], + "source": [ + "kubens default" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### list Pods running in your Namespace\n", + "kubectl pods will list all the pods running in the namespace" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "NAME READY STATUS RESTARTS AGE\n", + "mysql-1586443628-589d9d5fc5-4lpjq 1/1 Running 32 68d\n" + ] + } + ], + "source": [ + "kubectl get pods" ] }, { @@ -220,6 +299,37 @@ "# You are now Ready to start with the tutorials" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## List of Tutorials \n", + "\n", + "Data Engineer\n", + "\n", + "* Red\n", + "* Green\n", + "* Blue\n", + "\n", + "Data Scientist\n", + "\n", + "* Red\n", + "* Green\n", + "* Blue\n", + "\n", + "App Developer\n", + "\n", + "* Red\n", + "* Green\n", + "* Blue\n", + "\n", + "Operator\n", + "\n", + "* Red\n", + "* Green\n", + "* Blue" + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/tools/k8s-discovery.sh b/tools/k8s-discovery.sh new file mode 100755 index 0000000..e3fdb44 --- /dev/null +++ b/tools/k8s-discovery.sh @@ -0,0 +1,14 @@ +mkdir -p /home/${NB_USER}/data/k8sconfig/ +CLUSTERS=$(hpecp k8scluster list --columns [id,name] --output text | sed 1d | tr -s '[:blank:]' ',') +for CLUSTER in $CLUSTERS; +do + ID=$(echo $CLUSTER | cut -d ',' -f 1) + NAME=$(echo $CLUSTER | cut -d ',' -f 2) + hpecp k8scluster admin-kube-config $ID > /home/${NB_USER}/data/k8sconfig/${NAME}_kube.conf +done +unset KUBECONFIG +for i in $(find /home/${NB_USER}/data/k8sconfig/*_kube.conf -maxdepth 0 -type f) +do + export KUBECONFIG=$KUBECONFIG:${i} + done +/home/${NB_USER}/data/hpecp-tutorialbox-demo/tools/kubeconfigtweak.py