GithubHelp home page GithubHelp logo

container-service-getting-started-wt's Introduction

# IBM Cloud Kubernetes Service lab

An introduction to containers

Hey, are you looking for a containers 101 course? Check out our Docker Essentials.

Containers allow you to run securely isolated applications with quotas on system resources. Containers started out as an individual feature delivered with the linux kernel. Docker launched with making containers easy to use and developers quickly latched onto that idea. Containers have also sparked an interest in microservice architecture, a design pattern for developing applications in which complex applications are broken down into smaller, composable pieces which work together.

Watch this video to learn about production uses of containers.

Objectives

This lab is an introduction to using containers on Kubernetes in the IBM Cloud Kubernetes Service. By the end of the course, you'll achieve these objectives:

  • Understand core concepts of Kubernetes
  • Build a container image and deploy an application on Kubernetes in the IBM Cloud Kubernetes Service
  • Control application deployments, while minimizing your time with infrastructure management
  • Add AI services to extend your app
  • Secure and monitor your cluster and app

Prerequisites

Virtual machines

Prior to containers, most infrastructure ran not on bare metal, but atop hypervisors managing multiple virtualized operating systems (OSes). This arrangement allowed isolation of applications from one another on a higher level than that provided by the OS. These virtualized operating systems see what looks like their own exclusive hardware. However, this also means that each of these virtual operating systems are replicating an entire OS, taking up disk space.

Containers

Containers provide isolation similar to VMs, except provided by the OS and at the process level. Each container is a process or group of processes run in isolation. Typical containers explicitly run only a single process, as they have no need for the standard system services. What they usually need to do can be provided by system calls to the base OS kernel.

The isolation on linux is provided by a feature called 'namespaces'. Each different kind of isolation (IE user, cgroups) is provided by a different namespace.

This is a list of some of the namespaces that are commonly used and visible to the user:

  • PID - process IDs
  • USER - user and group IDs
  • UTS - hostname and domain name
  • NS - mount points
  • NET - network devices, stacks, and ports
  • CGROUPS - control limits and monitoring of resources

VM vs container

Traditional applications are run on native hardware. A single application does not typically use the full resources of a single machine. We try to run multiple applications on a single machine to avoid wasting resources. We could run multiple copies of the same application, but to provide isolation we use VMs to run multiple application instances (VMs) on the same hardware. These VMs have full operating system stacks which make them relatively large and inefficient due to duplication both at runtime and on disk.

Containers versus VMs

Containers allow you to share the host OS. This reduces duplication while still providing the isolation. Containers also allow you to drop unneeded files such as system libraries and binaries to save space and reduce your attack surface. If SSHD or LIBC are not installed, they cannot be exploited.

Get set up

Before we dive into Kubernetes, you need to provision a cluster for your containerized app. Then you won't have to wait for it to be ready for the subsequent labs.

  1. You must install the CLIs per https://cloud.ibm.com/docs/containers/cs_cli_install.html. If you do not yet have these CLIs and the Kubernetes CLI, do lab 0 before starting the course.
  2. If you haven't already, provision a cluster. This can take a few minutes, so let it start first: ibmcloud ks cluster create classic --name <name-of-cluster>
  3. After creation, before using the cluster, make sure it has completed provisioning and is ready for use. Run ibmcloud ks clusters and make sure that your cluster is in state "deployed".
  4. Then use ibmcloud ks workers --cluster <name-of-cluster> and make sure that all worker nodes are in state "normal" with Status "Ready".

Kubernetes and containers: an overview

Let's talk about Kubernetes orchestration for containers before we build an application on it. We need to understand the following facts about it:

  • What is Kubernetes, exactly?
  • How was Kubernetes created?
  • Kubernetes architecture
  • Kubernetes resource model
  • Kubernetes at IBM
  • Let's get started

What is Kubernetes?

Now that we know what containers are, let's define what Kubernetes is. Kubernetes is a container orchestrator to provision, manage, and scale applications. In other words, Kubernetes allows you to manage the lifecycle of containerized applications within a cluster of nodes (which are a collection of worker machines, for example, VMs, physical machines etc.).

Your applications may need many other resources to run such as Volumes, Networks, and Secrets that will help you to do things such as connect to databases, talk to firewalled backends, and secure keys. Kubernetes helps you add these resources into your application. Infrastructure resources needed by applications are managed declaratively.

Fast fact: Other orchestration technologies are Mesos and Swarm.

The key paradigm of kubernetes is it’s Declarative model. The user provides the "desired state" and Kubernetes will do it's best make it happen. If you need 5 instances, you do not start 5 separate instances on your own but rather tell Kubernetes that you need 5 instances and Kubernetes will reconcile the state automatically. Simply at this point you need to know that you declare the state you want and Kubernetes makes that happen. If something goes wrong with one of your instances and it crashes, Kubernetes still knows the desired state and creates a new instances on an available node.

Fun to know: Kubernetes goes by many names. Sometimes it is shortened to k8s (losing the internal 8 letters), or kube. The word is rooted in ancient Greek and means "Helmsman". A helmsman is the person who steers a ship. We hope you can seen the analogy between directing a ship and the decisions made to orchestrate containers on a cluster.

How was Kubernetes created?

Google wanted to open source their knowledge of creating and running the internal tools Borg & Omega. It adopted Open Governance for Kubernetes by starting the Cloud Native Computing Foundation (CNCF) and giving Kubernetes to that foundation, therefore making it less influenced by Google directly. Many companies such as RedHat, Microsoft, IBM and Amazon quickly joined the foundation.

Main entry point for the kubernetes project is at https://kubernetes.io/ and the source code can be found at https://github.com/kubernetes.

Kubernetes architecture

At its core, Kubernetes is a data store (etcd). The declarative model is stored in the data store as objects, that means when you say I want 5 instances of a container then that request is stored into the data store. This information change is watched and delegated to Controllers to take action. Controllers then react to the model and attempt to take action to achieve the desired state. The power of Kubernetes is in its simplistic model.

As shown, API server is a simple HTTP server handling create/read/update/delete(CRUD) operations on the data store. Then the controller picks up the change you wanted and makes that happen. Controllers are responsible for instantiating the actual resource represented by any Kubernetes resource. These actual resources are what your application needs to allow it to run successfully.

architecture diagram

Kubernetes resource model

Kubernetes Infrastructure defines a resource for every purpose. Each resource is monitored and processed by a controller. When you define your application, it contains a collection of these resources. This collection will then be read by Controllers to build your applications actual backing instances. Some of resources that you may work with are listed below for your reference, for a full list you should go to https://kubernetes.io/docs/concepts/. In this class we will only use a few of them, like Pod, Deployment, etc.

  • Config Maps holds configuration data for pods to consume.
  • Daemon Sets ensure that each node in the cluster runs this Pod
  • Deployments defines a desired state of a deployment object
  • Events provides lifecycle events on Pods and other deployment objects
  • Endpoints allows a inbound connections to reach the cluster services
  • Ingress is a collection of rules that allow inbound connections to reach the cluster services
  • Jobs creates one or more pods and as they complete successfully the job is marked as completed.
  • Node is a worker machine in Kubernetes
  • Namespaces are multiple virtual clusters backed by the same physical cluster
  • Pods are the smallest deployable units of computing that can be created and managed in Kubernetes
  • Persistent Volumes provides an API for users and administrators that abstracts details of how storage is provided from how it is consumed
  • Replica Sets ensures that a specified number of pod replicas are running at any given time
  • Secrets are intended to hold sensitive information, such as passwords, OAuth tokens, and ssh keys
  • Service Accounts provides an identity for processes that run in a Pod
  • Services is an abstraction which defines a logical set of Pods and a policy by which to access them - sometimes called a micro-service.
  • Stateful Sets is the workload API object used to manage stateful applications.
  • and more...

Relationship of pods, nodes, and containers

Kubernetes does not have the concept of an application. It has simple building blocks that you are required to compose. Kubernetes is a cloud native platform where the internal resource model is the same as the end user resource model.

Key resources

A Pod is the smallest object model that you can create and run. You can add labels to a pod to identify a subset to run operations on. When you are ready to scale your application you can use the label to tell Kubernetes which Pod you need to scale. A Pod typically represent a process in your cluster. Pods contain at least one container that runs the job and additionally may have other containers in it called sidecars for monitoring, logging, etc. Essentially a Pod is a group of containers.

When we talk about a application, we usually refer to group of Pods. Although an entire application can be run in a single Pod, we usually build multiple Pods that talk to each other to make a useful application. We will see why separating the application logic and backend database into separate Pods will scale better when we build an application shortly.

Services define how to expose your app as a DNS entry to have a stable reference. We use query based selector to choose which pods are supplying that service.

The user directly manipulates resources via yaml: $ kubectl (create|get|apply|delete) -f myResource.yaml

Kubernetes provides us with a client interface through ‘kubectl’. Kubectl commands allow you to manage your applications, manage cluster and cluster resources, by modifying the model in the data store.

Kubernetes application deployment workflow

deployment workflow

  1. User via "kubectl" deploys a new application. Kubectl sends the request to the API Server.
  2. API server receives the request and stores it in the data store (etcd). Once the request is written to data store, the API server is done with the request.
  3. Watchers detects the resource changes and send a notification to controller to act upon it
  4. Controller detects the new app and creates new pods to match the desired number# of instances. Any changes to the stored model will be picked up to create or delete Pods.
  5. Scheduler assigns new pods to a Node based on a criteria. Scheduler makes decisions to run Pods on specific Nodes in the cluster. Scheduler modifies the model with the node information.
  6. Kubelet on a node detects a pod with an assignment to itself, and deploys the requested containers via the container runtime (e.g. Docker). Each Node watches the storage to see what pods it is assigned to run. It takes necessary actions on resource assigned to it like create/delete Pods.
  7. Kubeproxy manages network traffic for the pods – including service discovery and load-balancing. Kubeproxy is responsible for communication between Pods that want to interact.

Lab information

IBM Cloud provides the capability to run applications in containers on Kubernetes. The IBM Cloud Kubernetes Service runs Kubernetes clusters which deliver the following:

  • Powerful tools
  • Intuitive user experience
  • Built-in security and isolation to enable rapid delivery of secure applications
  • Cloud services including cognitive capabilities from Watson
  • Capability to manage dedicated cluster resources for both stateless applications and stateful workloads

Lab overview

Lab 0 (Optional): Provides a walkthrough for installing IBM Cloud command-line tools and the Kubernetes CLI. You can skip this lab if you have the IBM Cloud CLI, the container-service plugin, the containers-registry plugin, and the kubectl CLI already installed on your machine.

Lab 1: This lab walks through creating and deploying a simple "hello world" app in Node.JS, then accessing that app.

Lab 2: Builds on lab 1 to expand to a more resilient setup which can survive having containers fail and recover. Lab 2 will also walk through basic services you need to get started with Kubernetes and the IBM Cloud Kubernetes Service

Lab 3: This lab covers adding external services to a cluster. It walks through adding integration to a Watson service, and discusses storing credentials of external services to the cluster.

Lab 4 (Under Construction, Paid Only, Optional): This lab will outline how to create a highly available application, and build on the knowledge you have learned in Labs 1 - 3 to deploy clusters simultaneously to multiple availability zones. As this requires a paid IBM Cloud account, skip this lab if you are sticking to the free tier.

Lab 5: This lab walks through securing your cluster and applications using network policies, and will later add leveraging tools like Vulnerability Advisor to secure images and manage security in your image registry.

container-service-getting-started-wt's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

container-service-getting-started-wt's Issues

Lab 2: healthz not working

In the Health Check section, I didn't get the same errors as described. Also, I couldn't get the healthz URL to work with this error message:
Cannot GET /healthz

So you'll see my PR removed the specific messages. I did see the pods appropriately restarting in the Kube dashboard.

Change folder names to Lab1 Lab2, etc.

Currently we have a space in the folder names. Should we remove the space? Not breaking as it is, but it does make writing instructions slightly more complicated (including quotes or escape characters) and possibly makes things trickier for people who are a bit less familiar w/the command line.

Lab 3 - watson-pod fails to start due to insufficient credentials to ToneAnalyzer

Lession 3a, step 7
kubectl apply -f watson-deployment.yml

After applying the deployment, the watson-pod fails to startup. Looking at the log, I see this error:

Error: Insufficient credentials provided in constructor argument. Refer to the documentation for the required parameters. Common examples are username/password, api_key, and iam_access_token.
at ToneAnalyzerV3.BaseService.initCredentials (/node_modules/watson-developer-cloud/lib/base_service.js:226:23)
at ToneAnalyzerV3.BaseService (/node_modules/watson-developer-cloud/lib/base_service.js:69:29)
at ToneAnalyzerV3 [as constructor] (/node_modules/watson-developer-cloud/tone-analyzer/v3-generated.js:54:28)
at new ToneAnalyzerV3 (/node_modules/watson-developer-cloud/tone-analyzer/v3.js:37:24)

Lab 1: ibmcloud 'cr' is not a registered command. See 'ibmcloud help'.

When attempting to walk through the documentation on Lab 1, we encounter an issue where when running the following:

Error:
[docker@linuxmachine ~]$ ibmcloud cr namespace-add my-test-namespace
FAILED
'cr' is not a registered command. See 'ibmcloud help'.

IBM Cloud Version:
VERSION:
0.19.0+94101c85-2019-09-23T03:46:57+00:00

Thanks.

deployment "hello-world" scaled is mixed with the command line

in the first step, it says:

  1. kubectl provides a scale subcommand to change the size of an
    existing deployment. Let's us it to go from our single running
    instance to 10 instances.

    $ kubectl scale --replicas=10 deployment hello-world
    deployment "hello-world" scaled

but it's better to separate the result and command, think about this. it's more clear for the script to be executed and avoid misunderstanding.

$ kubectl scale --replica=10 deployment hello-world

unauthorized: authentication required while push image to IBM Cloud Container Registry

[shubhrojyotide@oc8740175532 Desktop]$ ls -ltr |grep -i docker
drwxrwxr-x. 2 shubhrojyotide shubhrojyotide 4096 May 11 00:03 DockerFiles
[shubhrojyotide@oc8740175532 Desktop]$ cd DockerFiles

[shubhrojyotide@oc8740175532 DockerFiles]$ ls -ltr
total 4
-rw-rw-r--. 1 shubhrojyotide shubhrojyotide 153 May 11 00:03 Dockerfile

[shubhrojyotide@oc8740175532 DockerFiles]$ cat Dockerfile
FROM ubuntu
MAINTAINER Shubhrojyoti De
RUN apt-get update
CMD ["echo", "Hello World .. This is my first docker image"]

[shubhrojyotide@oc8740175532 DockerFiles]$ docker build --tag us.icr.io/k8-ns-shubhro/hello-world
"docker build" requires exactly 1 argument(s).
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile

[shubhrojyotide@oc8740175532 DockerFiles]$ docker build --tag us.icr.io/k8-ns-shubhro/hello-world .
Sending build context to Docker daemon 2.048 kB
Step 1/4 : FROM ubuntu
Trying to pull repository docker.io/library/ubuntu ...
latest: Pulling from docker.io/library/ubuntu
d51af753c3d3: Downloading [======> ] 3.808 MB/28.56 MB
fc878cd0a91c: Download complete
6154df8ff988: Download complete
fee5db0ff82f: Download complete
d51af753c3d3: Pull complete
fc878cd0a91c: Pull complete
6154df8ff988: Pull complete
fee5db0ff82f: Pull complete
Digest: sha256:747d2dbbaaee995098c9792d99bd333c6783ce56150d1b11e333bbceed5c54d7
Status: Downloaded newer image for docker.io/ubuntu:latest
---> 1d622ef86b13
Step 2/4 : MAINTAINER Shubhrojyoti De
---> Running in d446c75b4d86
---> 73a79e6fd4f6
Removing intermediate container d446c75b4d86
Step 3/4 : RUN apt-get update
---> Running in f85be82b9866
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:3 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [10.6 kB]
Get:4 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [39.8 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-updates InRelease [107 kB]
Get:6 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [1079 B]
Get:7 http://archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB]
Get:8 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [117 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [177 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [33.4 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1275 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB]
Get:13 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [126 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [224 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [10.6 kB]
Get:16 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [1079 B]
Get:17 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [2903 B]
Fetched 13.9 MB in 1min 19s (176 kB/s)
Reading package lists...
---> d9f3fd11769f
Removing intermediate container f85be82b9866
Step 4/4 : CMD echo Hello World .. This is my first docker image
---> Running in 1105ac985719
---> cae5ae9c5674
Removing intermediate container 1105ac985719
Successfully built cae5ae9c5674
[shubhrojyotide@oc8740175532 DockerFiles]$

[shubhrojyotide@oc8740175532 DockerFiles]$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
us.icr.io/k8-ns-shubhro/hello-world latest cae5ae9c5674 4 minutes ago 95.8 MB
docker.io/ubuntu latest 1d622ef86b13 6 weeks ago 73.9 MB
docker.io/hello-world latest bf756fb1ae65 5 months ago 13.3 kB

But again the problem comes here :

[shubhrojyotide@oc8740175532 DockerFiles]$ docker push us.icr.io/k8-ns-shubhro/hello-world:1
The push refers to a repository [us.icr.io/k8-ns-shubhro/hello-world]
d7fc1756ca5c: Preparing
8891751e0a17: Preparing
2a19bd70fcd4: Preparing
9e53fd489559: Preparing
7789f1a3d4e9: Preparing
unauthorized: authentication required

Any idea how to fix this ?

Lab 4 - No kubefed tarfile

This command curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/kubernetes-client-darwin-amd64.tar.gz

appears to be targetting the standard kubernetes cli, not kubernetes federation. Because I can't download the kubefed cli, I can't continue w/subsequent steps.

Lab 5 - we need to move this out of the course of get started

So I chatted with Jake Kitchener on this as I don't know how to complete some of the steps in lab 5.

https://github.com/IBM/container-service-getting-started-wt/tree/master/Lab%205#2-configure-the-calico-cli

we are asking users to enter etcd url
i don’t even know what that is, for calico config. Jake confirmed that this is documented but not trivial. It is for advanced operator functionality for network admins or security focal only. I'd vote us to remove this section of our k8s get started course.

Lab 1 Multiple security notices with some high vulnerability

While running the npm install multiple vulnerabilities are reported ...

 ---> Running in 752473c3231a
npm WARN notice [SECURITY] debug has the following vulnerability: 1 low. Go here for more details: https://www.npmjs.com/advisories?search=debug&version=2.2.0 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN deprecated [email protected]: connect 2.x series is deprecated
npm WARN notice [SECURITY] morgan has the following vulnerability: 1 moderate. Go here for more details: https://www.npmjs.com/advisories?search=morgan&version=1.6.1 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN notice [SECURITY] mime has the following vulnerability: 1 moderate. Go here for more details: https://www.npmjs.com/advisories?search=mime&version=1.3.4 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN notice [SECURITY] base64-url has the following vulnerability: 1 high. Go here for more details: https://www.npmjs.com/advisories?search=base64-url&version=1.2.1 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN notice [SECURITY] negotiator has the following vulnerability: 1 high. Go here for more details: https://www.npmjs.com/advisories?search=negotiator&version=0.5.3 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN notice [SECURITY] fresh has the following vulnerability: 1 high. Go here for more details: https://www.npmjs.com/advisories?search=fresh&version=0.3.0 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.

It looks like the version of Express is locked into an older release, can the repo be updated to use the latest?

docker build command returns authentication error

While testing the Lab 1 instructions, I got this error.

Vanessas-MBP:Lab 1 vwilburn$ docker build --tag registry.ng.bluemix.net/course_namespace/hello-world .
Sending build context to Docker daemon  13.82kB
Step 1/7 : FROM registry.ng.bluemix.net/ibmnode
Get https://registry.ng.bluemix.net/v2/ibmnode/manifests/latest: unauthorized: authentication required

Error: deployments.apps <namespace> not found

The instruction below would better to be corrected.

Lab1 2-2
Start by running your image as a deployment:
kubectl run hello-world --image=us.icr.io//hello-world:1

When I used the run command, only pod was created but deployment was not and at the Lab1 2-3, I encountered "Error: deployments.apps not found"

Instead of using run command, It seems better to use create deployment command, such as
kubectl create deployment hello-world --image=us.icr.io//hello-world:1

Lab 1 cluster provision cmd doesn't work

I think that cmd used to work when we only support us-south... but as you can see it failed for me. I think I'm pointed to us-east by default now. we need to tweak this cmd either by having user point to us-south first.

$ bx cs cluster-create --name test
Creating cluster...
The machine-type flag was not specified. So a lite cluster with default parameters will be created. To customize the parameters, create a standard cluster and include all required flags.
FAILED

Free clusters cannot be created in this region. Create a standard cluster. (E0141)
Incident ID: e5ca7fc2-8c03-44e7-babd-2ceb2e9c9525

Lab 1 - Error from server (NotFound): deployments.apps "hello-world" not found

Hi,

At Lab 1, step 3:

kubectl expose deployment/hello-world --type="NodePort" --port=8080

I received this message:

Error from server (NotFound): deployments.apps "hello-world" not found

To fix it, at Lab 1 at step 2, I changed from

run hello-world --image=us.icr.io/<my_namespace>/hello-world:1

to

kubectl create deployment hello-world --image=us.icr.io/<my_namespace>/hello-world:1

It solved some others problems along Lab 1 and Lab 2 too.

Lab 3 - watson-pod failing to start due to missing apikey

I have followed the instructions for lab 3 but watson-pod fails to start after creating it with kubectl create -f watson-deployment.yml. The output for that pod in kubectl get pods is

watson-pod-7d6f5d8fdf-4fhzm        0/1     CrashLoopBackOff   1          12s

The logs show the following:

/node_modules/ibm-cloud-sdk-core/auth/utils/helpers.js:63
        throw missingParamsError;
        ^

Error: Missing required parameters: apikey
    at Object.getMissingParams (/node_modules/ibm-cloud-sdk-core/lib/helper.js:102:11)
    at Object.validateInput (/node_modules/ibm-cloud-sdk-core/auth/utils/helpers.js:61:39)
    at new IamAuthenticator (/node_modules/ibm-cloud-sdk-core/auth/authenticators/iam-authenticator.js:47:17)
    at Object.getAuthenticatorFromEnvironment (/node_modules/ibm-cloud-sdk-core/auth/utils/get-authenticator-from-environment.js:63:29)
    at new ToneAnalyzerV3 (/node_modules/ibm-watson/tone-analyzer/v3.js:67:58)
    at Object.<anonymous> (/app.js:10:40)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)

Kubernetes Lab 1 : -bash: docker: command not found ( using cloudshell )

From Kuberenetes LAB 1 :
https://courses.cognitiveclass.ai/courses/course-v1:CognitiveClass+CO0201EN+v1/courseware/754094ea513a42f39ec84d99cae78249/f1cc315d40b74e1aa6ec1cd2a3c1f985/

Create a namespace in IBM Cloud Container Registry where you can store your images:
ibmcloud cr namespace-add <my_namespace> --------------------> I created k8-ns-shubhro

Build the example Docker image:
docker build --tag us.icr.io/<my_namespace>/hello-world . ---------------> This is failing

shubhrojyoti_de@cloudshell:~$ docker build --tag us.icr.io/k8-ns-shubhro/hello-world
-bash: docker: command not found

Please help on this.

Lab 1 - RUN npm install hangs

Hello, have somebody idea where could be problem. I adjust Dockerfile to find out on which line it hangs. I'm beginner in this linux/docker stuff.

FROM node:9.4.0-alpine
COPY app.js .
COPY package.json .
RUN npm install
RUN apk update
RUN apk upgrade
EXPOSE  8080
CMD node app.js

note: namespace - just for publication purpose

$ docker build --tag registry.eu-gb.bluemix.net/<namespace>/hello-world:1 .
Sending build context to Docker daemon  33.19MB
Step 1/8 : FROM node:9.4.0-alpine
9.4.0-alpine: Pulling from library/node
605ce1bd3f31: Pull complete 
fe58b30348fe: Pull complete 
46ef8987ccbd: Pull complete 
Digest: sha256:9cd67a00ed111285460a83847720132204185e9321ec35dacec0d8b9bf674adf
Status: Downloaded newer image for node:9.4.0-alpine
 ---> b5f94997f35f
Step 2/8 : COPY app.js .
 ---> 6e0d0af2f0fb
Step 3/8 : COPY package.json .
 ---> 037218cd0834
Step 4/8 : RUN npm install
 ---> Running in bae21d265ecf

Thanks!

lab 4 -- we need to tell users how to get these values

we gave this cmd:

bx cs cluster-create --name --machine-type b2c.4x16 --location --workers 2 --public-vlan --private-vlan

but there is no explanation on how to fill these values such as location public-clan and private-vlan.

Lab 2 scale failed "ImagePullBackOff"

I've finished Lab 1 successfully.

And I get deployment "hello-world" scaled no problem. But my rollout didn't succeed. it waited for rollout forever and then showed me error.
I tried debugging by running ibmcloud cr images,
it shows us.icr.io/yiyitest1/hello-world 1 de2d7cdc2e87 yiyitest1 18 hours ago 27 MB No Issues

and by running kubectl get pods ,
it shows hello-world-7bd7f9c949-9dx54 0/1 ImagePullBackOff 0 14h*10.

by running kubectl describe pod hello-world-7bd7f9c949-9dx54
it shows `Name: hello-world-7bd7f9c949-9dx54
Namespace: default
Priority: 0
Node: 10.144.213.119/10.144.213.119
Start Time: Wed, 17 Jun 2020 18:30:29 -0700
Labels: pod-template-hash=7bd7f9c949
run=hello-world
Annotations: kubernetes.io/psp: ibm-privileged-psp
Status: Pending
IP: 172.30.254.227
IPs:
IP: 172.30.254.227
Controlled By: ReplicaSet/hello-world-7bd7f9c949
Containers:
hello-world:
Container ID:
Image: us.icr.io/yiyitest1/hello-world
Image ID:
Port:
Host Port:
State: Waiting
Reason: ImagePullBackOff
Ready: False
Restart Count: 0
Environment:
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-lrbvt (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
default-token-lrbvt:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-lrbvt
Optional: false
QoS Class: BestEffort
Node-Selectors:
Tolerations: node.kubernetes.io/not-ready:NoExecute for 600s
node.kubernetes.io/unreachable:NoExecute for 600s
Events:
Type Reason Age From Message


Normal BackOff 43m (x3728 over 14h) kubelet, 10.144.213.119 Back-off pulling image "us.icr.io/yiyitest1/hello-world"
Warning Failed 3m58s (x3902 over 14h) kubelet, 10.144.213.119 Error: ImagePullBackOff`

I wonder if it matters that I am using a free cluster in ibm cloud.

Lab 5 - Command does not limit ingress

This command does not correctly limit ingress: kubectl annotate ns advanced-policy-demo "net.beta.kubernetes.io/network-policy={\"ingress\":{\"isolation\":\"DefaultDeny\"}}"

When we verify the YAML later in the lab, ingress is still set to allow:

- apiVersion: v1
  kind: profile
  metadata:
    name: k8s_ns.advanced-policy-demo
    tags:
    - k8s_ns.advanced-policy-demo
  spec:
    egress:
    - action: allow
      destination: {}
      source: {}
    ingress:
    - action: allow
      destination: {}
      source: {}

Slenderize Docker images by building upon Alpine Linux

Hey there,
I'd like to propose a change related to the base images used in the Node.js apps' Dockerfiles. Since they are currently derived from the node:6 Docker image, which is about 660MB in size, the final application image shows a total size of about 700MB.


$ docker images node:6 --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"
REPOSITORY          TAG                 SIZE
node                6                   662MB

$ docker images registry.ng.bluemix.net/hdmdemo/helloworld:1 --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"
REPOSITORY                                   TAG                 SIZE
registry.ng.bluemix.net/hdmdemo/helloworld   1                   702MB

Swapping the base image and using node:6-alpine instead reduces the overall image size by about 640MB:

$ docker images node:6-alpine --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"
REPOSITORY          TAG                 SIZE
node                6-alpine            54.7MB

$ docker images registry.ng.bluemix.net/hdmdemo/helloworld:alpine-1 --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"
REPOSITORY                                   TAG                 SIZE
registry.ng.bluemix.net/hdmdemo/helloworld   alpine-1            62.2MB

The modified Dockerfile I used for my experiments looks like this:

FROM node:6-alpine
COPY app.js .
COPY package.json .
RUN npm install
EXPOSE  8080
CMD node app.js

This makes creating and uploading images for the IBM Cloud tutorials much faster.
I'd gladly volunteer to prepare the necessary Dockerfile patches as a PR if you also consider this a valuable change.

Cheers,
Patrick

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.