Add docker-compose tag <service> <tag> and allow to push a specific tag by using push command
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
moved to Reopened awaiting QA template - Please move into To Test once added, thanks!
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_DIRECTis not set to true. This happens when Rancher is started either with the binary or with docker directly. When deploying Rancher withhelm, 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_DIRECTis true, verify that RemoteDialerProxy is not deployed. (kubectl -n cattle-system get deployments api-extensionreturns not found) kubectl get apiservice v1.ext.cattle.ioreturns not found in both cases- Still able to access
https://<rancher url>/ext/apis(make sure you set a valid rancher token inAuthorization: Bearer <token>header. This should give you a 200.
Feature is on
- Test that Rancher listens on
localhost:6666 - When
IMPERATIVE_API_DIRECTis not true:- verify that the service
api-extensionincattle-systempoints to the deploymentsapi-extensionincattle-system - verify that RemoteDialerProxy is deployed. (
kubectl -n cattle-system get deployments api-extensionreturns something)
- verify that the service
- When
IMPERATIVE_API_DIRECTis true:- verify that the service
api-extensionincattle-systempoints to Rancher - verify that RemoteDialerProxy is not deployed. (
kubectl -n cattle-system get deployments api-extensionreturns not found)
- verify that the service
kubectl get apiservice v1.ext.cattle.ioreturns 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-resourcesshows 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
...
๐งช 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 |
โ 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:// |
โ 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
kubectl -n cattle-system debug rancher-5ffc648559-l474t -it --image=alpine:latestapk add iproute2ss -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
- Run the following command
kubectl get service imperative-api-extension -n cattle-system -o yaml | grep -A 1 selector- 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
- Run the following command:
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
- Run the following command
kubectl get service imperative-api-extension -n cattle-system -o yaml | grep -A 1 selector- 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
- Run the following command:
kubectl -n cattle-system get deployments api-extension- 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
- Run the following command
kubectl get apiservice v1.ext.cattle.io- 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
- Run this command
kubectl api-resources | grep ext.cattle.io- 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
- Run the following command
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
kubectl -n cattle-system debug rancher-5ffc648559-l474t -it --image=alpine:latestapk add iproute2ss -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
- Run the following command
kubectl get apiservice v1.ext.cattle.io- 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
- Visit
https://<rancher url>/ext/apis - 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
- 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
- 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
- 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
- Upgrade rancher
- Rerun all test cases
โ Expected Outcome
All passing
โ Actual Outcome
All passing