# Use an Image

# List images

Get a list of which images you have built so far within your namespace by using the kp image list -n <namespace> command as described here (opens new window) in detail.

$ kp image list -n mycloud
NAME                 READY    LATEST REASON    LATEST IMAGE                                                                                                                                          NAMESPACE
demo-golang-image    True     CONFIG           harbor.demo.kube-plus.cloud/mycloud/java-demo@sha256:01c602ec30d4f079c39812944f1ef15f9e94a8decffefaae064ef150ab0970f2    mycloud
demo-java-image      True     CONFIG           harbor.demo.kube-plus.cloud/mycloud/java-demo@sha256:26fd8a53e33ebfefbd434f5cfd001852cf4cd4d572dcdd50956db90ca0af2fe9    mycloud
demo-simple-image    True     CONFIG           harbor.demo.kube-plus.cloud/mycloud/java-demo@sha256:1ae0555bd3f4d7de11f7926b8e883d72a0085e010deb5f7d974fdfbf9f55dba3    mycloud

# View image status

Get a look at the image status, which buildpacks have been used, etc. by using the kp image status <image-name> -n <namespace> command as described here (opens new window) in detail.

$ kp image status demo-simple-image -n mycloud
Status:         Ready
Message:        --
LatestImage:    harbor.demo.kube-plus.cloud/mycloud/java-demo@sha256:1ae0555bd3f4d7de11f7926b8e883d72a0085e010deb5f7d974fdfbf9f55dba3

Builder Ref:
  Name:         default-builder
  Kind:         ClusterBuilder

Last Successful Build
Id:              1
Build Reason:    CONFIG

BUILDPACK ID                         BUILDPACK VERSION    HOMEPAGE
paketo-buildpacks/ca-certificates    2.4.2                https://github.com/paketo-buildpacks/ca-certificates
paketo-buildpacks/go-dist            0.7.0                https://github.com/paketo-buildpacks/go-dist
paketo-buildpacks/go-build           0.5.0                https://github.com/paketo-buildpacks/go-build

Last Failed Build
Id:              --
Build Reason:    --

# Deploy an app with an image

Once you know the URL of your newly built image you can then deploy it as an application by either using a simple Knative service specification or by any other Kubernetes primitive that will use your image, like a Pod or Deployment, etc.:

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: my-knative-app
  namespace: mycloud
spec:
  template:
    spec:
      containers: # specify your image URL here:
      - image: harbor.demo.kube-plus.cloud/mycloud/java-demo@sha256:01c602ec30d4f079c39812944f1ef15f9e94a8decffefaae064ef150ab0970f2
$ kubectl apply -n mycloud -f knative-app.yaml

or

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
  namespace: mycloud
spec:
  replicas: 2
  selector:
    matchLabels:
      app: simple-app
  template:
    metadata:
      labels:
        app: simple-app
    spec:
      containers:
      - name: app
        # specify your image URL here:
        image: harbor.demo.kube-plus.cloud/mycloud/java-demo@sha256:01c602ec30d4f079c39812944f1ef15f9e94a8decffefaae064ef150ab0970f2
        ports:
        - containerPort: 8080
$ kubectl apply -n mycloud -f kubernetes-deployment.yaml
Last Updated: 3/1/2022, 4:15:49 PM