Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Merge remote-tracking branch 'upstream/main' into fix-assoc-with-cust…
…om-cert-without-ca
  • Loading branch information
thbkrkr committed Feb 16, 2022
commit 83155d994acfb2f5909f6f340cbb175679d2f5fe
48 changes: 0 additions & 48 deletions pkg/controller/apmserver/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"k8s.io/apimachinery/pkg/types"

apmv1 "github.com/elastic/cloud-on-k8s/pkg/apis/apm/v1"
"github.com/elastic/cloud-on-k8s/pkg/controller/common/association"
"github.com/elastic/cloud-on-k8s/pkg/controller/common/certificates"
"github.com/elastic/cloud-on-k8s/pkg/controller/common/deployment"
"github.com/elastic/cloud-on-k8s/pkg/controller/common/keystore"
Expand Down Expand Up @@ -92,53 +91,6 @@ func (r *ReconcileApmServer) deploymentParams(
return deployment.Params{}, err
}

if err := association.WriteAssocsToConfigHash(r.Client, as.GetAssociations(), configChecksum); err != nil {
return deployment.Params{}, err
}

for _, assoc := range as.GetAssociations() {
if assoc.AssociationConf().CAIsConfigured() {
caVolume := volume.NewSecretVolumeWithMountPath(
assoc.AssociationConf().GetCASecretName(),
fmt.Sprintf("%s-certs", assoc.AssociationType()),
filepath.Join(ApmBaseDir, certificatesDir(assoc.AssociationType())),
)
podSpec.Spec.Volumes = append(podSpec.Spec.Volumes, caVolume.Volume())

for i := range podSpec.Spec.InitContainers {
podSpec.Spec.InitContainers[i].VolumeMounts = append(podSpec.Spec.InitContainers[i].VolumeMounts, caVolume.VolumeMount())
}

for i := range podSpec.Spec.Containers {
podSpec.Spec.Containers[i].VolumeMounts = append(podSpec.Spec.Containers[i].VolumeMounts, caVolume.VolumeMount())
}
}
}

if as.Spec.HTTP.TLS.Enabled() {
// fetch the secret to calculate the checksum
var httpCerts corev1.Secret
err := r.Get(context.Background(), types.NamespacedName{
Namespace: as.Namespace,
Name: certificates.InternalCertsSecretName(Namer, as.Name),
}, &httpCerts)
if err != nil {
return deployment.Params{}, err
}
if httpCert, ok := httpCerts.Data[certificates.CertFileName]; ok {
_, _ = configChecksum.Write(httpCert)
}
httpCertsVolume := certificates.HTTPCertSecretVolume(Namer, as.Name)
podSpec.Spec.Volumes = append(podSpec.Spec.Volumes, httpCertsVolume.Volume())
apmServerContainer := pod.ContainerByName(podSpec.Spec, apmv1.ApmServerContainerName)
apmServerContainer.VolumeMounts = append(apmServerContainer.VolumeMounts, httpCertsVolume.VolumeMount())
}

// add secret token to hash to force pod rotation on change
_, _ = configChecksum.Write(params.TokenSecret.Data[SecretTokenKey])

podSpec.Labels[configChecksumLabelName] = fmt.Sprintf("%x", configChecksum.Sum(nil))

return deployment.Params{
Name: Deployment(as.Name),
Namespace: as.Namespace,
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.