Skip to content

Commit a3d31f2

Browse files
committed
Use jujud-operator as the k8s docker image; use juju-db:4.1.9 for mongo, new repo config option
1 parent a34c3d2 commit a3d31f2

File tree

12 files changed

+114
-54
lines changed

12 files changed

+114
-54
lines changed

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,24 +148,24 @@ operator-image: install caas/jujud-operator-dockerfile caas/jujud-operator-requi
148148
cp ${JUJUD_BIN_DIR}/jujud ${JUJUD_STAGING_DIR}
149149
cp caas/jujud-operator-dockerfile ${JUJUD_STAGING_DIR}
150150
cp caas/jujud-operator-requirements.txt ${JUJUD_STAGING_DIR}
151-
docker build -f ${JUJUD_STAGING_DIR}/jujud-operator-dockerfile -t ${DOCKER_USERNAME}/caas-jujud-operator:${OPERATOR_IMAGE_TAG} ${JUJUD_STAGING_DIR}
151+
docker build -f ${JUJUD_STAGING_DIR}/jujud-operator-dockerfile -t ${DOCKER_USERNAME}/jujud-operator:${OPERATOR_IMAGE_TAG} ${JUJUD_STAGING_DIR}
152152
rm -rf ${JUJUD_STAGING_DIR}
153153

154154
push-operator-image: operator-image
155-
docker push ${DOCKER_USERNAME}/caas-jujud-operator:${OPERATOR_IMAGE_TAG}
155+
docker push ${DOCKER_USERNAME}/jujud-operator:${OPERATOR_IMAGE_TAG}
156156

157157
microk8s-operator-update: operator-image
158-
docker save ${DOCKER_USERNAME}/caas-jujud-operator:${OPERATOR_IMAGE_TAG} | microk8s.docker load
158+
docker save ${DOCKER_USERNAME}/jujud-operator:${OPERATOR_IMAGE_TAG} | microk8s.docker load
159159

160160
check-k8s-model:
161161
@:$(if $(value JUJU_K8S_MODEL),, $(error Undefined JUJU_K8S_MODEL))
162162
@juju show-model ${JUJU_K8S_MODEL} > /dev/null
163163

164164
local-operator-update: check-k8s-model operator-image
165165
$(eval kubeworkers != juju status -m ${JUJU_K8S_MODEL} kubernetes-worker --format json | jq -c '.machines | keys' | tr -c '[:digit:]' ' ' 2>&1)
166-
docker save ${DOCKER_USERNAME}/caas-jujud-operator:${OPERATOR_IMAGE_TAG} | gzip > /tmp/caas-jujud-operator-image.tar.gz
167-
$(foreach wm,$(kubeworkers), juju scp -m ${JUJU_K8S_MODEL} /tmp/caas-jujud-operator-image.tar.gz $(wm):/tmp/caas-jujud-operator-image.tar.gz ; )
168-
$(foreach wm,$(kubeworkers), juju ssh -m ${JUJU_K8S_MODEL} $(wm) -- "zcat /tmp/caas-jujud-operator-image.tar.gz | docker load" ; )
166+
docker save ${DOCKER_USERNAME}/jujud-operator:${OPERATOR_IMAGE_TAG} | gzip > /tmp/jujud-operator-image.tar.gz
167+
$(foreach wm,$(kubeworkers), juju scp -m ${JUJU_K8S_MODEL} /tmp/jujud-operator-image.tar.gz $(wm):/tmp/jujud-operator-image.tar.gz ; )
168+
$(foreach wm,$(kubeworkers), juju ssh -m ${JUJU_K8S_MODEL} $(wm) -- "zcat /tmp/jujud-operator-image.tar.gz | docker load" ; )
169169

170170
.PHONY: build check install release-install release-build go-build go-install
171171
.PHONY: clean format simplify

acceptancetests/assess_caas_deploy_charms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def parse_args(argv):
269269
parser = argparse.ArgumentParser(description="Cass charm deployment CI test")
270270
parser.add_argument(
271271
'--caas-image', action='store', default=None,
272-
help='Caas operator docker image name to use with format of <username>/caas-jujud-operator:<tag>.'
272+
help='Caas operator docker image name to use with format of <username>/jujud-operator:<tag>.'
273273
)
274274

275275
add_basic_testing_arguments(parser, existing=False)

apiserver/facades/controller/caasoperatorprovisioner/mock_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type mockState struct {
2727
model *mockModel
2828
applicationWatcher *mockStringsWatcher
2929
app *mockApplication
30-
operatorImage string
30+
operatorRepo string
3131
}
3232

3333
func newMockState() *mockState {
@@ -51,7 +51,7 @@ func (st *mockState) FindEntity(tag names.Tag) (state.Entity, error) {
5151

5252
func (st *mockState) ControllerConfig() (controller.Config, error) {
5353
cfg := coretesting.FakeControllerConfig()
54-
cfg[controller.CAASOperatorImagePath] = st.operatorImage
54+
cfg[controller.CAASImageRepo] = st.operatorRepo
5555
return cfg, nil
5656
}
5757

apiserver/facades/controller/caasoperatorprovisioner/provisioner_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (s *CAASProvisionerSuite) TestOperatorProvisioningInfoDefault(c *gc.C) {
123123
result, err := s.api.OperatorProvisioningInfo()
124124
c.Assert(err, jc.ErrorIsNil)
125125
c.Assert(result, jc.DeepEquals, params.OperatorProvisioningInfo{
126-
ImagePath: fmt.Sprintf("jujusolutions/caas-jujud-operator:%s", version.Current.String()),
126+
ImagePath: fmt.Sprintf("jujusolutions/jujud-operator:%s", version.Current.String()),
127127
Version: version.Current,
128128
APIAddresses: []string{"10.0.0.1:1"},
129129
Tags: map[string]string{
@@ -145,11 +145,11 @@ func (s *CAASProvisionerSuite) TestOperatorProvisioningInfoDefault(c *gc.C) {
145145
}
146146

147147
func (s *CAASProvisionerSuite) TestOperatorProvisioningInfo(c *gc.C) {
148-
s.st.operatorImage = "jujusolutions/caas-jujud-operator"
148+
s.st.operatorRepo = "somerepo"
149149
result, err := s.api.OperatorProvisioningInfo()
150150
c.Assert(err, jc.ErrorIsNil)
151151
c.Assert(result, jc.DeepEquals, params.OperatorProvisioningInfo{
152-
ImagePath: s.st.operatorImage,
152+
ImagePath: s.st.operatorRepo + "/jujud-operator:" + version.Current.String(),
153153
Version: version.Current,
154154
APIAddresses: []string{"10.0.0.1:1"},
155155
Tags: map[string]string{
@@ -172,11 +172,11 @@ func (s *CAASProvisionerSuite) TestOperatorProvisioningInfo(c *gc.C) {
172172

173173
func (s *CAASProvisionerSuite) TestOperatorProvisioningInfoNoStoragePool(c *gc.C) {
174174
s.storagePoolManager.SetErrors(errors.NotFoundf("pool"))
175-
s.st.operatorImage = "jujusolutions/caas-jujud-operator"
175+
s.st.operatorRepo = "somerepo"
176176
result, err := s.api.OperatorProvisioningInfo()
177177
c.Assert(err, jc.ErrorIsNil)
178178
c.Assert(result, jc.DeepEquals, params.OperatorProvisioningInfo{
179-
ImagePath: s.st.operatorImage,
179+
ImagePath: s.st.operatorRepo + "/jujud-operator:" + version.Current.String(),
180180
Version: version.Current,
181181
APIAddresses: []string{"10.0.0.1:1"},
182182
Tags: map[string]string{

caas/kubernetes/provider/bootstrap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ func (c controllerStack) buildContainerSpecForController(statefulset *apps.State
533533
containerSpec = append(containerSpec, core.Container{
534534
Name: "mongodb",
535535
ImagePullPolicy: core.PullIfNotPresent,
536-
Image: "mongo:3.6.6",
536+
Image: c.pcfg.GetJujuDbOCIImagePath(),
537537
Command: []string{
538538
"mongod",
539539
},

caas/kubernetes/provider/bootstrap_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
core "k8s.io/api/core/v1"
1212
k8sstorage "k8s.io/api/storage/v1"
1313
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14-
intstr "k8s.io/apimachinery/pkg/util/intstr"
14+
"k8s.io/apimachinery/pkg/util/intstr"
1515

1616
"github.com/juju/juju/api"
1717
"github.com/juju/juju/apiserver/params"
@@ -309,7 +309,7 @@ func (s *bootstrapSuite) TestBootstrap(c *gc.C) {
309309
{
310310
Name: "mongodb",
311311
ImagePullPolicy: core.PullIfNotPresent,
312-
Image: "mongo:3.6.6",
312+
Image: s.pcfg.GetJujuDbOCIImagePath(),
313313
Command: []string{
314314
"mongod",
315315
},

caas/kubernetes/provider/k8s_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,14 @@ func (s *K8sSuite) TestOperatorPodConfig(c *gc.C) {
337337
tags := map[string]string{
338338
"juju-operator": "gitlab",
339339
}
340-
pod := provider.OperatorPod("gitlab", "gitlab", "/var/lib/juju", "jujusolutions/caas-jujud-operator", "2.99.0", tags)
340+
pod := provider.OperatorPod("gitlab", "gitlab", "/var/lib/juju", "jujusolutions/jujud-operator", "2.99.0", tags)
341341
c.Assert(pod.Name, gc.Equals, "gitlab")
342342
c.Assert(pod.Labels, jc.DeepEquals, map[string]string{
343343
"juju-operator": "gitlab",
344344
"juju-version": "2.99.0",
345345
})
346346
c.Assert(pod.Spec.Containers, gc.HasLen, 1)
347-
c.Assert(pod.Spec.Containers[0].Image, gc.Equals, "jujusolutions/caas-jujud-operator")
347+
c.Assert(pod.Spec.Containers[0].Image, gc.Equals, "jujusolutions/jujud-operator")
348348
c.Assert(pod.Spec.Containers[0].VolumeMounts, gc.HasLen, 1)
349349
c.Assert(pod.Spec.Containers[0].VolumeMounts[0].MountPath, gc.Equals, "/var/lib/juju/agents/application-gitlab/template-agent.conf")
350350
}

cloudconfig/podcfg/podcfg.go

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ var logger = loggo.GetLogger("juju.cloudconfig.podcfg")
3232

3333
const (
3434
jujudOCINamespace = "jujusolutions"
35-
jujudOCIName = "caas-jujud-operator"
35+
jujudOCIName = "jujud-operator"
36+
jujudbOCIName = "juju-db:4.1.9"
3637
)
3738

3839
// ControllerPodConfig represents initialization information for a new juju caas controller pod.
@@ -226,13 +227,27 @@ func (cfg *ControllerPodConfig) GetControllerImagePath() string {
226227
return GetJujuOCIImagePath(cfg.Controller.Config, cfg.JujuVersion)
227228
}
228229

229-
// GetJujuOCIImagePath returns jujud oci image path.
230+
// GetJUjuDbOCIImagePath returns the juju-db oci image path.
231+
func (cfg *ControllerPodConfig) GetJujuDbOCIImagePath() string {
232+
imageRepo := cfg.Controller.Config.CAASImageRepo()
233+
if imageRepo == "" {
234+
imageRepo = jujudOCINamespace
235+
}
236+
return fmt.Sprintf("%s/%s", imageRepo, jujudbOCIName)
237+
}
238+
239+
// GetJujuOCIImagePath returns the jujud oci image path.
230240
func GetJujuOCIImagePath(controllerCfg controller.Config, ver version.Number) string {
241+
// First check the deprecated "caas-operator-image-path" config.
231242
imagePath := controllerCfg.CAASOperatorImagePath()
232-
if imagePath == "" {
233-
imagePath = fmt.Sprintf("%s/%s:%s", jujudOCINamespace, jujudOCIName, ver.String())
243+
if imagePath != "" {
244+
return imagePath
245+
}
246+
imageRepo := controllerCfg.CAASImageRepo()
247+
if imageRepo == "" {
248+
imageRepo = jujudOCINamespace
234249
}
235-
return imagePath
250+
return fmt.Sprintf("%s/%s:%s", imageRepo, jujudOCIName, ver.String())
236251
}
237252

238253
func (cfg *ControllerPodConfig) verifyBootstrapConfig() (err error) {

cloudconfig/podcfg/podcfg_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package podcfg_test
55

66
import (
77
jc "github.com/juju/testing/checkers"
8+
"github.com/juju/version"
89
gc "gopkg.in/check.v1"
910

1011
"github.com/juju/juju/cloudconfig/podcfg"
@@ -52,3 +53,28 @@ func testPodLabels(c *gc.C, cfg *config.Config, jobs []multiwatcher.MachineJob,
5253
tags := podcfg.PodLabels(testing.ModelTag.Id(), testing.ControllerTag.Id(), cfg, jobs)
5354
c.Assert(tags, jc.DeepEquals, expectTags)
5455
}
56+
57+
func (*podcfgSuite) TestOperatorImagesDefaultRepo(c *gc.C) {
58+
cfg := testing.FakeControllerConfig()
59+
podConfig, err := podcfg.NewBootstrapControllerPodConfig(
60+
cfg,
61+
"kubernetes",
62+
)
63+
c.Assert(err, jc.ErrorIsNil)
64+
podConfig.JujuVersion = version.MustParse("6.6.6")
65+
c.Assert(podConfig.GetControllerImagePath(), gc.Equals, "jujusolutions/jujud-operator:6.6.6")
66+
c.Assert(podConfig.GetJujuDbOCIImagePath(), gc.Equals, "jujusolutions/juju-db:4.1.9")
67+
}
68+
69+
func (*podcfgSuite) TestOperatorImagesCustomRepo(c *gc.C) {
70+
cfg := testing.FakeControllerConfig()
71+
cfg["caas-image-repo"] = "path/to/my/repo"
72+
podConfig, err := podcfg.NewBootstrapControllerPodConfig(
73+
cfg,
74+
"kubernetes",
75+
)
76+
c.Assert(err, jc.ErrorIsNil)
77+
podConfig.JujuVersion = version.MustParse("6.6.6")
78+
c.Assert(podConfig.GetControllerImagePath(), gc.Equals, "path/to/my/repo/jujud-operator:6.6.6")
79+
c.Assert(podConfig.GetJujuDbOCIImagePath(), gc.Equals, "path/to/my/repo/juju-db:4.1.9")
80+
}

controller/config.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,13 @@ const (
227227

228228
// CAASOperatorImagePath sets the url of the docker image
229229
// used for the application operator.
230+
// Deprecated: use CAASImageRepo
230231
CAASOperatorImagePath = "caas-operator-image-path"
231232

233+
// CAASImageRepo sets the docker repo to use
234+
// for the jujud operator and mongo images.
235+
CAASImageRepo = "caas-image-repo"
236+
232237
// Features allows a list of runtime changeable features to be updated.
233238
Features = "features"
234239

@@ -269,6 +274,7 @@ var (
269274
AuditLogMaxBackups,
270275
AuditLogExcludeMethods,
271276
CAASOperatorImagePath,
277+
CAASImageRepo,
272278
Features,
273279
MeteringURL,
274280
}
@@ -293,6 +299,7 @@ var (
293299
JujuHASpace,
294300
JujuManagementSpace,
295301
CAASOperatorImagePath,
302+
CAASImageRepo,
296303
Features,
297304
)
298305

@@ -630,6 +637,12 @@ func (c Config) CAASOperatorImagePath() string {
630637
return c.asString(CAASOperatorImagePath)
631638
}
632639

640+
// CAASImageRepo sets the url of the docker repo
641+
// used for the jujud operator and mongo images.
642+
func (c Config) CAASImageRepo() string {
643+
return c.asString(CAASImageRepo)
644+
}
645+
633646
// MeteringURL returns the URL to use for metering api calls.
634647
func (c Config) MeteringURL() string {
635648
url := c.asString(MeteringURL)
@@ -712,7 +725,13 @@ func Validate(c Config) error {
712725
return errors.Trace(err)
713726
}
714727

715-
if v, ok := c[CAASOperatorImagePath].(string); ok {
728+
if v, ok := c[CAASOperatorImagePath].(string); ok && v != "" {
729+
if err := resources.ValidateDockerRegistryPath(v); err != nil {
730+
return errors.Trace(err)
731+
}
732+
}
733+
734+
if v, ok := c[CAASImageRepo].(string); ok && v != "" {
716735
if err := resources.ValidateDockerRegistryPath(v); err != nil {
717736
return errors.Trace(err)
718737
}
@@ -853,6 +872,7 @@ var configChecker = schema.FieldMap(schema.Fields{
853872
JujuHASpace: schema.String(),
854873
JujuManagementSpace: schema.String(),
855874
CAASOperatorImagePath: schema.String(),
875+
CAASImageRepo: schema.String(),
856876
Features: schema.List(schema.String()),
857877
CharmStoreURL: schema.String(),
858878
MeteringURL: schema.String(),
@@ -883,6 +903,7 @@ var configChecker = schema.FieldMap(schema.Fields{
883903
JujuHASpace: schema.Omit,
884904
JujuManagementSpace: schema.Omit,
885905
CAASOperatorImagePath: schema.Omit,
906+
CAASImageRepo: schema.Omit,
886907
Features: schema.Omit,
887908
CharmStoreURL: csclient.ServerURL,
888909
MeteringURL: romulus.DefaultAPIRoot,

controller/config_test.go

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -189,45 +189,45 @@ var validateTests = []struct {
189189
},
190190
expectError: `invalid audit log exclude methods: should be a list of "Facade.Method" names \(or "ReadOnlyMethods"\), got "Sharon Jones" at position 3`,
191191
}, {
192-
about: "invalid CAAS operator docker image path",
192+
about: "invalid CAAS docker image repo",
193193
config: controller.Config{
194-
controller.CACertKey: testing.CACert,
195-
controller.CAASOperatorImagePath: "foo?bar",
194+
controller.CACertKey: testing.CACert,
195+
controller.CAASImageRepo: "foo?bar",
196196
},
197197
expectError: `docker image path "foo\?bar" not valid`,
198198
}, {
199-
about: "invalid CAAS operator docker image path - leading colon",
199+
about: "invalid CAAS operator docker image repo - leading colon",
200200
config: controller.Config{
201-
controller.CACertKey: testing.CACert,
202-
controller.CAASOperatorImagePath: ":foo",
201+
controller.CACertKey: testing.CACert,
202+
controller.CAASImageRepo: ":foo",
203203
},
204204
expectError: `docker image path ":foo" not valid`,
205205
}, {
206-
about: "invalid CAAS operator docker image path - trailing colon",
206+
about: "invalid CAAS docker image repo - trailing colon",
207207
config: controller.Config{
208-
controller.CACertKey: testing.CACert,
209-
controller.CAASOperatorImagePath: "foo:",
208+
controller.CACertKey: testing.CACert,
209+
controller.CAASImageRepo: "foo:",
210210
},
211211
expectError: `docker image path "foo:" not valid`,
212212
}, {
213-
about: "invalid CAAS operator docker image path - extra colon",
213+
about: "invalid CAAS docker image repo - extra colon",
214214
config: controller.Config{
215-
controller.CACertKey: testing.CACert,
216-
controller.CAASOperatorImagePath: "foo::bar",
215+
controller.CACertKey: testing.CACert,
216+
controller.CAASImageRepo: "foo::bar",
217217
},
218218
expectError: `docker image path "foo::bar" not valid`,
219219
}, {
220-
about: "invalid CAAS operator docker image path - leading /",
220+
about: "invalid CAAS docker image repo - leading /",
221221
config: controller.Config{
222-
controller.CACertKey: testing.CACert,
223-
controller.CAASOperatorImagePath: "/foo",
222+
controller.CACertKey: testing.CACert,
223+
controller.CAASImageRepo: "/foo",
224224
},
225225
expectError: `docker image path "/foo" not valid`,
226226
}, {
227-
about: "invalid CAAS operator docker image path - extra /",
227+
about: "invalid CAAS docker image repo - extra /",
228228
config: controller.Config{
229-
controller.CACertKey: testing.CACert,
230-
controller.CAASOperatorImagePath: "foo//bar",
229+
controller.CACertKey: testing.CACert,
230+
controller.CAASImageRepo: "foo//bar",
231231
},
232232
expectError: `docker image path "foo//bar" not valid`,
233233
}, {
@@ -498,25 +498,22 @@ func (s *ConfigSuite) TestConfigNoSpacesNilSpaceConfigPreserved(c *gc.C) {
498498
c.Check(cfg.AsSpaceConstraints(nil), gc.IsNil)
499499
}
500500

501-
func (s *ConfigSuite) TestCAASOperatorImagePath(c *gc.C) {
502-
for _, imagePath := range []string{
503-
"juju-operator-image",
504-
"registry.foo.com/juju-operator-image",
505-
"registry.foo.com/me/juju-operator-image",
506-
"juju-operator-image:latest",
507-
"juju-operator-image:2.4-beta1",
508-
"registry.foo.com/juju-operator-image:2.4-beta1",
509-
"registry.foo.com/me/juju-operator-image:2.4-beta1",
501+
func (s *ConfigSuite) TestCAASImageRepo(c *gc.C) {
502+
for _, imageRepo := range []string{
503+
"", //used to reset since we don't have a --reset option
504+
"juju-operator-repo",
505+
"registry.foo.com",
506+
"registry.foo.com/me",
510507
} {
511508
cfg, err := controller.NewConfig(
512509
testing.ControllerTag.Id(),
513510
testing.CACert,
514511
map[string]interface{}{
515-
controller.CAASOperatorImagePath: imagePath,
512+
controller.CAASImageRepo: imageRepo,
516513
},
517514
)
518515
c.Assert(err, jc.ErrorIsNil)
519-
c.Assert(cfg.CAASOperatorImagePath(), gc.Equals, imagePath)
516+
c.Assert(cfg.CAASImageRepo(), gc.Equals, imageRepo)
520517
}
521518
}
522519

state/controller_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func (s *ControllerSuite) TestControllerAndModelConfigInitialisation(c *gc.C) {
4343
controller.MaxLogsSize,
4444
controller.MaxLogsAge,
4545
controller.CAASOperatorImagePath,
46+
controller.CAASImageRepo,
4647
controller.CharmStoreURL,
4748
controller.Features,
4849
controller.MeteringURL,

0 commit comments

Comments
 (0)