Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/install/_static/Dockerfile.terraform_deployer
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM hashicorp/terraform:light
ENV TF_IN_AUTOMATION=true
HEALTHCHECK --timeout=3s CMD sh -c "[ -f /tmp/tf-applied ]"
ADD run.sh /
WORKDIR /workspace
ENTRYPOINT sh /run.sh
6 changes: 6 additions & 0 deletions internal/install/_static/kibana_healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -e

curl -s -f http://127.0.0.1:5601/login | grep kbn-injected-metadata 2>&1 >/dev/null
curl -s -f -u elastic:changeme "http://elasticsearch:9200/_cat/indices/.security-*?h=health" | grep -v red
9 changes: 9 additions & 0 deletions internal/install/_static/terraform_deployer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '2.3'
services:
terraform:
build: .
tty: true
environment:
- TF_VAR_TEST_RUN_ID=${TF_VAR_TEST_RUN_ID:-detached}
volumes:
- ${TF_DIR}:/stage
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package install

const terraformDeployerRun = `#!sh
#!sh

set -euxo pipefail

Expand All @@ -28,4 +22,3 @@ echo "Terraform definitions applied."

set +x
while true; do sleep 1; done # wait for ctrl-c
`
19 changes: 19 additions & 0 deletions internal/install/static.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package install

import _ "embed"

//go:embed _static/kibana_healthcheck.sh
var kibanaHealthcheckSh string

//go:embed _static/Dockerfile.terraform_deployer
var terraformDeployerDockerfile string

//go:embed _static/terraform_deployer.yml
var terraformDeployerYml string

//go:embed _static/terraform_deployer_run.sh
var terraformDeployerRun string
13 changes: 0 additions & 13 deletions internal/install/static_kibana_healthcheck_sh.go

This file was deleted.

13 changes: 0 additions & 13 deletions internal/install/static_terraform_deployer_dockerfile.go

This file was deleted.

16 changes: 0 additions & 16 deletions internal/install/static_terraform_deployer_yml.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,81 +1,4 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package kubectl

const singleDefinitionFile = `apiVersion: v1
kind: Service
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app.kubernetes.io/name":"kube-state-metrics","app.kubernetes.io/version":"2.0.0-rc.1"},"name":"kube-state-metrics","namespace":"kube-system"},"spec":{"clusterIP":"None","ports":[{"name":"http-metrics","port":8080,"targetPort":"http-metrics"},{"name":"telemetry","port":8081,"targetPort":"telemetry"}],"selector":{"app.kubernetes.io/name":"kube-state-metrics"}}}
creationTimestamp: "2021-04-13T10:50:22Z"
labels:
app.kubernetes.io/name: kube-state-metrics
app.kubernetes.io/version: 2.0.0-rc.1
managedFields:
- apiVersion: v1
fieldsType: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
.: {}
f:kubectl.kubernetes.io/last-applied-configuration: {}
f:labels:
.: {}
f:app.kubernetes.io/name: {}
f:app.kubernetes.io/version: {}
f:spec:
f:clusterIP: {}
f:ports:
.: {}
k:{"port":8080,"protocol":"TCP"}:
.: {}
f:name: {}
f:port: {}
f:protocol: {}
f:targetPort: {}
k:{"port":8081,"protocol":"TCP"}:
.: {}
f:name: {}
f:port: {}
f:protocol: {}
f:targetPort: {}
f:selector:
.: {}
f:app.kubernetes.io/name: {}
f:sessionAffinity: {}
f:type: {}
manager: kubectl
operation: Update
time: "2021-04-13T10:50:22Z"
name: kube-state-metrics
namespace: kube-system
resourceVersion: "630"
uid: 12a3a777-97bf-476d-9a96-4c9265bdb7d9
spec:
clusterIP: None
clusterIPs:
- None
ports:
- name: http-metrics
port: 8080
protocol: TCP
targetPort: http-metrics
- name: telemetry
port: 8081
protocol: TCP
targetPort: telemetry
selector:
app.kubernetes.io/name: kube-state-metrics
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
`

const multipleDefinitionFiles = `apiVersion: v1
apiVersion: v1
items:
- apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand Down Expand Up @@ -584,4 +507,3 @@ items:
loadBalancer: {}
kind: List
metadata: {}
`
69 changes: 69 additions & 0 deletions internal/kubectl/kube-state-metrics-single.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
apiVersion: v1
kind: Service
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app.kubernetes.io/name":"kube-state-metrics","app.kubernetes.io/version":"2.0.0-rc.1"},"name":"kube-state-metrics","namespace":"kube-system"},"spec":{"clusterIP":"None","ports":[{"name":"http-metrics","port":8080,"targetPort":"http-metrics"},{"name":"telemetry","port":8081,"targetPort":"telemetry"}],"selector":{"app.kubernetes.io/name":"kube-state-metrics"}}}
creationTimestamp: "2021-04-13T10:50:22Z"
labels:
app.kubernetes.io/name: kube-state-metrics
app.kubernetes.io/version: 2.0.0-rc.1
managedFields:
- apiVersion: v1
fieldsType: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
.: {}
f:kubectl.kubernetes.io/last-applied-configuration: {}
f:labels:
.: {}
f:app.kubernetes.io/name: {}
f:app.kubernetes.io/version: {}
f:spec:
f:clusterIP: {}
f:ports:
.: {}
k:{"port":8080,"protocol":"TCP"}:
.: {}
f:name: {}
f:port: {}
f:protocol: {}
f:targetPort: {}
k:{"port":8081,"protocol":"TCP"}:
.: {}
f:name: {}
f:port: {}
f:protocol: {}
f:targetPort: {}
f:selector:
.: {}
f:app.kubernetes.io/name: {}
f:sessionAffinity: {}
f:type: {}
manager: kubectl
operation: Update
time: "2021-04-13T10:50:22Z"
name: kube-state-metrics
namespace: kube-system
resourceVersion: "630"
uid: 12a3a777-97bf-476d-9a96-4c9265bdb7d9
spec:
clusterIP: None
clusterIPs:
- None
ports:
- name: http-metrics
port: 8080
protocol: TCP
targetPort: http-metrics
- name: telemetry
port: 8081
protocol: TCP
targetPort: telemetry
selector:
app.kubernetes.io/name: kube-state-metrics
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
7 changes: 7 additions & 0 deletions internal/kubectl/kubectl_apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@
package kubectl

import (
_ "embed"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

//go:embed kube-state-metrics-single.yaml
var singleDefinitionFile string

//go:embed kube-state-metrics-multiple.yaml
var multipleDefinitionFiles string

func TestExtractResources_singleDefinition(t *testing.T) {
r, err := extractResources([]byte(singleDefinitionFile))
require.NoError(t, err)
Expand Down
5 changes: 5 additions & 0 deletions internal/profile/_static/Dockerfile.package-registry
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM __BASE_IMAGE__

ARG PROFILE
COPY profiles/${PROFILE}/stack/package-registry.config.yml /package-registry/config.yml
COPY stack/development/ /packages/development
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package profile

import (
"path/filepath"
)

// SnapshotFile is the docker-compose snapshot.yml file name
const SnapshotFile configFile = "snapshot.yml"

const snapshotYml = `version: '2.3'
version: '2.3'
services:
elasticsearch:
image: "${ELASTICSEARCH_IMAGE_REF}"
Expand Down Expand Up @@ -138,13 +125,3 @@ services:
depends_on:
elastic-agent:
condition: service_healthy
`

// newSnapshotFile returns a Managed Config
func newSnapshotFile(_ string, profilePath string) (*simpleFile, error) {
return &simpleFile{
name: string(SnapshotFile),
path: filepath.Join(profilePath, profileStackPath, string(SnapshotFile)),
body: snapshotYml,
}, nil
}
16 changes: 16 additions & 0 deletions internal/profile/_static/kibana_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
server.name: kibana
server.host: "0.0.0.0"

elasticsearch.hosts: [ "http://elasticsearch:9200" ]
elasticsearch.username: elastic
elasticsearch.password: changeme

xpack.monitoring.ui.container.elasticsearch.enabled: true

xpack.fleet.enabled: true
xpack.fleet.registryUrl: "http://package-registry:8080"
xpack.fleet.agents.enabled: true
xpack.fleet.agents.elasticsearch.host: "http://elasticsearch:9200"
xpack.fleet.agents.fleet_server.hosts: ["http://fleet-server:8220"]

xpack.encryptedSavedObjects.encryptionKey: "12345678901234567890123456789012"
5 changes: 5 additions & 0 deletions internal/profile/_static/package_registry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package_paths:
- /packages/development
- /packages/production
- /packages/staging
- /packages/snapshot
Loading