Skip to content

Commit

Permalink
Revert "Remove unused manifests (#638)"
Browse files Browse the repository at this point in the history
This reverts commit a9c1e99.
  • Loading branch information
danielm-codefresh committed Nov 10, 2022
1 parent a9c1e99 commit 4f59067
Show file tree
Hide file tree
Showing 28 changed files with 726 additions and 13 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=v0.1.5
VERSION=v0.1.4

OUT_DIR=dist
YEAR?=$(shell date +"%Y")
Expand All @@ -9,6 +9,7 @@ IMAGE_NAMESPACE?=codefresh

RUNTIME_DEF_URL="https://raw.githubusercontent.com/codefresh-io/csdp-official/stable/csdp/hybrid/basic/runtime.yaml"
ADD_CLUSTER_DEF_URL="https://github.com/codefresh-io/csdp-official/add-cluster/kustomize"
FALLBACK_ADD_CLUSTER_DEF_URL="https://github.com/codefresh-io/cli-v2/manifests/add-cluster/kustomize"

# when developing, point this to your local clone of csdp-official
DEV_RUNTIME_DEF_URL="https://raw.githubusercontent.com/codefresh-io/csdp-official/stable/csdp/hybrid/basic/runtime.yaml"
Expand Down Expand Up @@ -105,6 +106,7 @@ $(OUT_DIR)/$(CLI_NAME)-%: $(CLI_SRCS)
GIT_COMMIT=$(GIT_COMMIT) \
RUNTIME_DEF_URL=$(RUNTIME_DEF_URL) \
ADD_CLUSTER_DEF_URL=$(ADD_CLUSTER_DEF_URL) \
FALLBACK_ADD_CLUSTER_DEF_URL=$(FALLBACK_ADD_CLUSTER_DEF_URL) \
SEGMENT_WRITE_KEY=$(SEGMENT_WRITE_KEY) \
DEV_MODE=$(DEV_MODE) \
OUT_FILE=$(OUT_DIR)/$(CLI_NAME)-$* \
Expand Down
94 changes: 94 additions & 0 deletions build/add-cluster-script.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
version: '1.0'
mode: parallel

stages:
- Prepare
- Test
- Release

steps:
main_clone:
stage: Prepare
title: clone repository
type: git-clone
git: cf_github
repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
revision: ${{CF_BRANCH}}

prepare_env_vars:
stage: Prepare
title: prepare-env
image: codefresh/semver:latest
working_directory: manifests/add-cluster
commands:
- cf_export CHART_VERSION=$(yq ".version" helm/Chart.yaml | tr -d '"')
- cf_export IMAGE_VERSION=$(yq ".appVersion" helm/Chart.yaml | tr -d '"')
when:
steps:
- name: main_clone
on:
- success

compare_versions:
stage: Test
title: Compare versions
image: codefresh/semver:latest
commands:
- hack/compare-versions.sh
when:
steps:
- name: prepare_env_vars
on:
- success

build_image:
stage: Release
type: build
title: build and push add-cluster image
working_directory: manifests/add-cluster
image_name: codefresh/csdp-add-cluster
tag: ${{IMAGE_VERSION}}
tags:
- latest
- ${{IMAGE_VERSION}}
registry: ${{REGISTRY_INTEGRATION_QUAY}}
buildkit: true
when:
steps:
- name: compare_versions
on:
- success
branch:
only: ["main"]

build_dev_image:
stage: Release
type: build
title: build and push add-cluster dev image
working_directory: manifests/add-cluster
image_name: codefresh/csdp-add-cluster
tag: ${{CF_BRANCH}}
registry: ${{REGISTRY_INTEGRATION_QUAY}}
buildkit: true
when:
steps:
- name: compare_versions
on:
- success
branch:
ignore: ["main"]

publish_chart:
stage: Release
title: publish helm chart
image: quay.io/codefresh/golang-ci-helper:latest # change it
working_directory: manifests/add-cluster
environment:
- CHART_VERSION=${{CHART_VERSION}}
commands:
- echo "inside publish helm chart ${CHART_VERSION}"
when:
steps:
- name: build_image
on:
- success
18 changes: 14 additions & 4 deletions cmd/commands/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type (
)

var (
minAddClusterSupportedVersion = semver.MustParse("0.0.283")
minAddClusterSupportedVersion = semver.MustParse("0.0.283")
minAddClusterLabelsSupportedVersion = semver.MustParse("0.0.462")

serviceAccountGVK = resid.Gvk{
Expand Down Expand Up @@ -384,7 +384,7 @@ func createAddClusterManifests(opts *ClusterAddOptions, ingressUrl, server, csdp
return nil, "", fmt.Errorf("failed encoding annotations: %w", err)
}

k.ConfigMapGenerator[0].KvPairSources.LiteralSources = append(k.ConfigMapGenerator[0].KvPairSources.LiteralSources, fmt.Sprintf("annotations="+annotationsStr))
k.ConfigMapGenerator[0].KvPairSources.LiteralSources = append(k.ConfigMapGenerator[0].KvPairSources.LiteralSources, fmt.Sprintf("annotations=" + annotationsStr))
}

if len(opts.labels) > 0 {
Expand All @@ -393,7 +393,7 @@ func createAddClusterManifests(opts *ClusterAddOptions, ingressUrl, server, csdp
return nil, "", fmt.Errorf("failed encoding labels: %w", err)
}

k.ConfigMapGenerator[0].KvPairSources.LiteralSources = append(k.ConfigMapGenerator[0].KvPairSources.LiteralSources, fmt.Sprintf("labels="+labelsStr))
k.ConfigMapGenerator[0].KvPairSources.LiteralSources = append(k.ConfigMapGenerator[0].KvPairSources.LiteralSources, fmt.Sprintf("labels=" + labelsStr))
}

if opts.tag != "" {
Expand All @@ -410,7 +410,17 @@ func createAddClusterManifests(opts *ClusterAddOptions, ingressUrl, server, csdp

manifests, err := kustutil.BuildKustomization(k)
if err != nil {
return nil, "", fmt.Errorf("failed to build kustomization: %w", err)
// go to fallback add-cluster manifests
// remove this once all manifests has been moved official-csdp repo.
// once we are sure no one will be looking for those manifests in cli-v2 we can remove this.
fallbackResourceUrl := fmt.Sprintf("%s?ref=v%s", store.FallbackAddClusterDefURL, version)
k.Resources[0] = fallbackResourceUrl
log.G().Warnf("Failed to get \"add-cluster\" manifests from %s, using fallback of %s", resourceUrl, fallbackResourceUrl)

manifests, err = kustutil.BuildKustomization(k)
if err != nil {
return nil, "", fmt.Errorf("failed to build kustomization: %w", err)
}
}

return manifests, nameSuffix, nil
Expand Down
4 changes: 2 additions & 2 deletions docs/releases/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cf version

```bash
# download and extract the binary
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.5/cf-linux-amd64.tar.gz | tar zx
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.4/cf-linux-amd64.tar.gz | tar zx

# move the binary to your $PATH
mv ./cf-linux-amd64 /usr/local/bin/cf
Expand All @@ -36,7 +36,7 @@ cf version

```bash
# download and extract the binary
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.5/cf-darwin-amd64.tar.gz | tar zx
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.4/cf-darwin-amd64.tar.gz | tar zx

# move the binary to your $PATH
mv ./cf-darwin-amd64 /usr/local/bin/cf
Expand Down
19 changes: 19 additions & 0 deletions hack/compare-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# used by the add-cluster-script.yaml
# compares the helm chart version with the kustomization image version to make sure they are identical

BASE_DIRECTORY="manifests/add-cluster"
HELM_CHART="${BASE_DIRECTORY}/helm/Chart.yaml"
KUSTOMIZATION_YAML="${BASE_DIRECTORY}/kustomize/kustomization.yaml"

HELM_VERSION=$(yq ".appVersion" ${HELM_CHART} | tr -d '"')
KUST_VERSION=$(yq '.images | select(.[].name == "quay.io/codefresh/csdp-add-cluster") | .[0].newTag' ${KUSTOMIZATION_YAML} | tr -d '"')
if ! semver-cli equal ${HELM_VERSION} ${KUST_VERSION}; then
echo "mismatched versions:"
echo "helm/Chart.yaml appVersion = ${HELM_VERSION}"
echo "kustomize/kustomization.yaml newTag = ${KUST_VERSION}"
exit 1
fi

echo "helm and kustomize versions match: ${HELM_VERSION}"
8 changes: 8 additions & 0 deletions manifests/add-cluster/kustomize/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- https://github.com/codefresh-io/csdp-official/add-cluster/kustomize
# This file is here for users with runtime version > 0.0.417 but with clis < 0.0.417
# That will try to look for the add-cluster manifests in this location instead of
# csdp-official repo. We should remove this when we think clis < 0.0.417 are no longer
# in use.
7 changes: 7 additions & 0 deletions manifests/app-proxy/app-proxy.cm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cap-app-proxy-cm
data:
argoCdUsername: admin
argoCdInsecure: "true"
12 changes: 12 additions & 0 deletions manifests/app-proxy/app-proxy.crb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: cap-app-proxy-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: argo-server-cluster-role
subjects:
- kind: ServiceAccount
name: cap-app-proxy
namespace: default
152 changes: 152 additions & 0 deletions manifests/app-proxy/app-proxy.deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: cap-app-proxy
name: cap-app-proxy
spec:
selector:
matchLabels:
app: cap-app-proxy
template:
metadata:
labels:
app: cap-app-proxy
spec:
serviceAccountName: cap-app-proxy
containers:
- env:
- name: ARGO_CD_URL
valueFrom:
configMapKeyRef:
name: cap-app-proxy-cm
key: argoCdUrl
optional: true
- name: ARGO_CD_USERNAME
valueFrom:
configMapKeyRef:
name: cap-app-proxy-cm
key: argoCdUsername
optional: true
- name: ARGO_CD_PASSWORD
valueFrom:
secretKeyRef:
name: argocd-initial-admin-secret
key: password
- name: ARGO_CD_INSECURE
valueFrom:
configMapKeyRef:
name: cap-app-proxy-cm
key: argoCdInsecure
- name: ARGO_WORKFLOWS_INSECURE
valueFrom:
configMapKeyRef:
name: cap-app-proxy-cm
key: argoWorkflowsInsecure
- name: ARGO_WORKFLOWS_URL
valueFrom:
configMapKeyRef:
name: cap-app-proxy-cm
key: argoWorkflowsUrl
optional: true
- name: CF_HOST
valueFrom:
configMapKeyRef:
name: cap-app-proxy-cm
key: cfHost
optional: true
- name: CORS
valueFrom:
configMapKeyRef:
name: cap-app-proxy-cm
key: cors
optional: true
- name: ENV
valueFrom:
configMapKeyRef:
name: cap-app-proxy-cm
key: env
optional: true
- name: GRAPHQL_DEBUG
valueFrom:
configMapKeyRef:
name: cap-app-proxy-cm
key: graphqlDebug
optional: true
- name: GRAPHQL_PLAYGROUND
valueFrom:
configMapKeyRef:
name: cap-app-proxy-cm
key: graphqlPlayground
optional: true
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: PORT
valueFrom:
configMapKeyRef:
name: cap-app-proxy-cm
key: port
optional: true
- name: REPOS_DIR
valueFrom:
configMapKeyRef:
name: cap-app-proxy-cm
key: reposDir
optional: true
- name: RUNTIME_NAME
valueFrom:
configMapKeyRef:
name: cap-app-proxy-cm
key: runtimeName
optional: true
- name: RUNTIME_TOKEN
valueFrom:
secretKeyRef:
name: codefresh-token
key: token
- name: RUNTIME_STORE_IV
valueFrom:
secretKeyRef:
name: codefresh-token
key: encryptionIV
optional: true
- name: STORE_BACKEND
valueFrom:
configMapKeyRef:
name: cap-app-proxy-cm
key: storeBackend
optional: true
- name: STRIP_PREFIX
valueFrom:
configMapKeyRef:
name: cap-app-proxy-cm
key: stripPrefix
optional: true
image: quay.io/codefresh/cap-app-proxy
imagePullPolicy: Always
name: cap-app-proxy
readinessProbe:
initialDelaySeconds: 10
timeoutSeconds: 10
httpGet:
port: http
path: /api/readyz
livenessProbe:
initialDelaySeconds: 10
timeoutSeconds: 10
failureThreshold: 10
httpGet:
port: http
path: /api/healthz
ports:
- name: http
containerPort: 80
resources:
requests:
memory: "256Mi"
cpu: "100m"
limits:
memory: "2048Mi"
cpu: "2"
13 changes: 13 additions & 0 deletions manifests/app-proxy/app-proxy.rb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
labels:
app: cap-app-proxy
name: cap-app-proxy
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: cap-app-proxy
subjects:
- kind: ServiceAccount
name: cap-app-proxy
Loading

0 comments on commit 4f59067

Please sign in to comment.