compose icon indicating copy to clipboard operation
compose copied to clipboard

Add docker-compose tag <service> <tag> and allow to push a specific tag by using push command

Open Jokero opened this issue 5 years ago โ€ข 18 comments

Is your feature request related to a problem? Please describe. I have several applications with their own Dockerfile within one project and in order to build, launch and test them locally I'm using docker-compose.

It seems like a good idea to reuse docker-compose commands to build, test and push images to registry from CI, so I decided to use them in Jenkinsfile. Project has package.json file with current version which is incremented during CI build. This version is used as tag for docker images.

docker-compose.yaml:

version: '2'

services:
  app1:
    image: my-registry.com/app1
    build:
      context: ./app1
    // other fields
  app2:
    image: my-registry.com/app2
    build:
      context: ./app2
    // other fields
  app3:
    image: my-registry.com/app3
    build:
      context: ./app3
    // other fields

The current CI pipeline looks as follows:

1) Build images
docker-compose build // generates images with "latest" tag

2) Test images
docker-compose run --rm app1 <test command> // the same for app2 and app3

3) If tests passed, increment version and use it as the next docker tag
npm version <patch/minor/major>
newVersion = readJSON('package.json').version

4) Tag and push images
composeServices = readYaml('docker-compose.yaml').services // { app1: { image: my-registry.com/app1 }, ... }
image = composeServices.app1.image // the same for app2 and app3
docker tag <image> <image>:<newVersion>
docker push <image>:<newVersion>

This pipeline works but I have to read compose file to get image that will be used in "docker tag" and "docker push" commands.

Describe the solution you'd like I'd like to have a new command:

docker-compose tag <service> <tag>
// for my example
docker-compose tag app1 <version from updated package.json>

And I want "push" command to support tag postfix:

docker-compose push <service>:<tag>
// for my example
docker-compose push app1:<version from updated package.json>

Describe alternatives you've considered Using "docker tag" and "docker push" explicitly but for that I need to read images from docker-compose.yaml file

Jokero avatar Aug 14 '20 14:08 Jokero

moved to Reopened awaiting QA template - Please move into To Test once added, thanks!

brudnak avatar Feb 24 '25 17:02 brudnak

QA Testing

Root cause

N/A

What was fixed, or what changes have occurred

We're adding a new feature imperative-api-extension that will be off by default.

When turned on:

  • A new HTTPS server is started listening on port localhost:6666
  • This server should be reachable by Kubernetes either directly (when IMPERATIVE_API_DIRECT=true) or indirectly otherwise.
  • RemoteDialerProxy is deployed when IMPERATIVE_API_DIRECT is not set to true. This happens when Rancher is started either with the binary or with docker directly. When deploying Rancher with helm, then RemoteDialer is not deployed.
  • A APIService for ext.cattle.io should be deployed. (We're still deploying one even though we don't have any store.. It's fine..)

Areas or cases that should be tested

What areas could experience regressions?

Rancher startup sequence when the feature is on, both with or without IMPERATIVE_API_DIRECT=true. This is because we're adding new CustomResources to Kubernetes, which may or may not be available right away based (especially true if we're waiting for RDP to be deployed).

Steps

Feature is off

  • Test that Rancher doesn't listen on localhost:6666.
  • When IMPERATIVE_API_DIRECT is true, verify that RemoteDialerProxy is not deployed. (kubectl -n cattle-system get deployments api-extension returns not found)
  • kubectl get apiservice v1.ext.cattle.io returns not found in both cases
  • Still able to access https://<rancher url>/ext/apis (make sure you set a valid rancher token in Authorization: Bearer <token> header. This should give you a 200.

Feature is on

  • Test that Rancher listens on localhost:6666
  • When IMPERATIVE_API_DIRECT is not true:
    • verify that the service api-extension in cattle-system points to the deployments api-extension in cattle-system
    • verify that RemoteDialerProxy is deployed. (kubectl -n cattle-system get deployments api-extension returns something)
  • When IMPERATIVE_API_DIRECT is true:
    • verify that the service api-extension in cattle-system points to Rancher
    • verify that RemoteDialerProxy is not deployed. (kubectl -n cattle-system get deployments api-extension returns not found)
  • kubectl get apiservice v1.ext.cattle.io returns the following (note that "True" column is important and says that everything is working fine. This might take a few seconds to get a "True" column:
$ kubectl get apiservice v1.ext.cattle.io 
NAME               SERVICE                                  AVAILABLE   AGE
v1.ext.cattle.io   cattle-system/imperative-api-extension   True        137m
  • kubectl api-resources shows at least one CustomResource from the ext.cattle.io group:
$ kubectl api-resources | grep ext.cattle.io
useractivities                                            ext.cattle.io/v1                  false        UserActivity
  • kubectl explain <resource> works for these resources:
$ kubectl explain useractivities
GROUP:      ext.cattle.io
KIND:       UserActivity
VERSION:    v1
...

tomleb avatar Feb 24 '25 21:02 tomleb

๐Ÿงช Test Environment... CLICK TO EXPAND! โฌ…๏ธ
Component Version / Type
Rancher version v2.11.0-alpha12
Installation option Helm (high availability)
If Helm Chart k8s cluster v1.31.2
Cert Details external tls aws acm
Docker version 20.10.7, build f0df350
Downstream cluster type N/A
Downstream K8s version N/A
Authentication providers enabled local
Logged in user role admin
Webhook version rancher/rancher-webhook:v0.7.0-rc.9

๐Ÿงช Test Cases

# Priority Description & Link PASS/FAIL
1 P0 (Feat. on) local listening :6666 โœ… PASS
2 P0 (Feat. on) Docker install service points to api-extension โœ… PASS
3 P0 (Feat. on) Docker install RemoteDialerProxy deployed โœ… PASS
4 P0 (Feat. on) Helm install service points to rancher โœ… PASS
5 P0 (Feat. on) Helm Install RemoteDialerProxy not deployed โœ… PASS
6 P0 (Feat. on) apiservice v1.ext.cattle.io returns avail true โœ… PASS
7 P0 (Feat. on) kubectl api-resources shows at least one CustomResource โœ… PASS
8 P0 (Feat. on) kubectl explain works for these resources โœ… PASS
9 P0 (Feat. off) Local doesn't listen on :6666 โœ… PASS
10 P0 (Feat. off) apiservice v1.ext.cattle.io returns not found โœ… PASS
11 P0 (Feat. off) Still able to access https:///ext/apis โœ… PASS
12 P0 (Regression Test) Steve filter โœ… PASS
13 P0 (Regression Test) Steve limit โœ… PASS
14 P0 (Regression Test) Steve sort โœ… PASS
15 P0 Upgrade โœ… PASS
๐Ÿšจ 15 test cases... CLICK TO EXPAND! (For table links to work) โฌ…๏ธ

1 / (Feat. on) local listening :6666 Status: โœ… PASS

:small_red_triangle: back to top

Test 1 details... Click to expand

Test Steps for Validation

  1. kubectl -n cattle-system debug rancher-5ffc648559-l474t -it --image=alpine:latest
  2. apk add iproute2
  3. ss -lntp

โœ… Expected Outcome

Port listening on :6666

โœ… Actual Outcome

Port listening on :6666


2 / (Feat. on) Docker install service points to api-extension Status: โœ… PASS

:small_red_triangle: back to top

Test 2 details... Click to expand

Test Steps for Validation

  1. Run the following command
  2. kubectl get service imperative-api-extension -n cattle-system -o yaml | grep -A 1 selector
  3. Ensure that the selector points to api-extension

โœ… Expected Outcome

Selector set to api-extension

โœ… Actual Outcome

Selector was api-extension

kubectl get service imperative-api-extension -n cattle-system -o yaml | grep -A 1 selector
  selector:

3 / (Feat. on) Docker install RemoteDialerProxy deployed Status: โœ… PASS

:small_red_triangle: back to top

Test 3 details... Click to expand

Test Steps for Validation

  1. Run the following command:
  2. kubectl -n cattle-system get deployments api-extension

โœ… Expected Outcome

Should return a deployment

โœ… Actual Outcome

It does return a deployment

NAME            READY   UP-TO-DATE   AVAILABLE   AGE
api-extension   1/1     1            1           70s

4 / (Feat. on) Helm install service points to rancher Status: โœ… PASS

:small_red_triangle: back to top

Test 4 details... Click to expand

Test Steps for Validation

  1. Run the following command
  2. kubectl get service imperative-api-extension -n cattle-system -o yaml | grep -A 1 selector
  3. Ensure that the selector points to rancher

โœ… Expected Outcome

Selector set to Rancher

โœ… Actual Outcome

Selector was rancher

% kubectl get service imperative-api-extension -n cattle-system -o yaml | grep -A 1 selector

  selector:
    app: rancher

5 / (Feat. on) Helm Install RemoteDialerProxy not deployed Status: โœ… PASS

:small_red_triangle: back to top

Test 5 details... Click to expand

Test Steps for Validation

  1. Run the following command:
  2. kubectl -n cattle-system get deployments api-extension
  3. Should return not found

โœ… Expected Outcome

Should return not found

โœ… Actual Outcome

Deployment was not found as expected


6 / (Feat. on) apiservice v1.ext.cattle.io returns avail true Status: โœ… PASS

:small_red_triangle: back to top

Test 6 details... Click to expand

Test Steps for Validation

  1. Run the following command
  2. kubectl get apiservice v1.ext.cattle.io
  3. Should return true for available

โœ… Expected Outcome

Available column to be set as true

โœ… Actual Outcome

Available was true


7 / (Feat. on) kubectl api-resources shows at least one CustomResource Status: โœ… PASS

:small_red_triangle: back to top

Test 7 details... Click to expand

Test Steps for Validation

  1. Run this command
  2. kubectl api-resources | grep ext.cattle.io
  3. Should return one resource at least

โœ… Expected Outcome

One resource at least to be returned

โœ… Actual Outcome

andrewbrudnak@Andrews-MacBook-Pro Downloads % kubectl api-resources | grep ext.cattle.io
useractivities                                            ext.cattle.io/v1                  false        UserActivity

8 / (Feat. on) kubectl explain works for these resources Status: โœ… PASS

:small_red_triangle: back to top

Test 8 details... Click to expand

Test Steps for Validation

  1. Run the following command
  2. kubectl explain useractivities

โœ… Expected Outcome

Should get user activities returned

โœ… Actual Outcome

Got user activities returned


9 / (Feat. off) Local doesn't listen on :6666 Status: โœ… PASS

:small_red_triangle: back to top

Test 9 details... Click to expand

Test Steps for Validation

  1. kubectl -n cattle-system debug rancher-5ffc648559-l474t -it --image=alpine:latest
  2. apk add iproute2
  3. ss -lntp

โœ… Expected Outcome

No port listening on :6666

โœ… Actual Outcome

No port listening on :666


10 / (Feat. off) apiservice v1.ext.cattle.io returns not found Status: โœ… PASS

:small_red_triangle: back to top

Test 10 details... Click to expand

Test Steps for Validation

  1. Run the following command
  2. kubectl get apiservice v1.ext.cattle.io
  3. Should return true for available

โœ… Expected Outcome

Error from server (NotFound): apiservices.apiregistration.k8s.io "v1.ext.cattle.io" not found

โœ… Actual Outcome

Error from server (NotFound): apiservices.apiregistration.k8s.io "v1.ext.cattle.io" not found


11 / (Feat. off) Still able to access https:///ext/apis Status: โœ… PASS

:small_red_triangle: back to top

Test 11 details... Click to expand

Test Steps for Validation

  1. Visit https://<rancher url>/ext/apis
  2. 200 returned

โœ… Expected Outcome

200 returned

โœ… Actual Outcome

200 returned


12 / (Regression Test) Steve filter Status: โœ… PASS

:small_red_triangle: back to top

Test 12 details... Click to expand

Test Steps for Validation

  1. Automated check

โœ… Expected Outcome

Passing

โœ… Actual Outcome

Passing


13 / (Regression Test) Steve limit Status: โœ… PASS

:small_red_triangle: back to top

Test 13 details... Click to expand

Test Steps for Validation

  1. Automated check

โœ… Expected Outcome

Passing

โœ… Actual Outcome

Passing


14 / (Regression Test) Steve sort Status: โœ… PASS

:small_red_triangle: back to top

Test 14 details... Click to expand

Test Steps for Validation

  1. Automated check

โœ… Expected Outcome

Passing

โœ… Actual Outcome

Passing


15 / Upgrade Status: โœ… PASS

:small_red_triangle: back to top

Test 15 details... Click to expand

Test Steps for Validation

  1. Upgrade rancher
  2. Rerun all test cases

โœ… Expected Outcome

All passing

โœ… Actual Outcome

All passing


brudnak avatar Mar 13 '25 10:03 brudnak