Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Last active January 18, 2022 00:21
Show Gist options
  • Save vfarcic/8719daeb09034dd4dfbeccd73fa8e301 to your computer and use it in GitHub Desktop.
Save vfarcic/8719daeb09034dd4dfbeccd73fa8e301 to your computer and use it in GitHub Desktop.
# Source: https://gist.github.com/8719daeb09034dd4dfbeccd73fa8e301
################################################################################################################
# Graduated Ninjas Do NOT Use UIs: Using CLI To Configure Codefresh And Create And Manage Kubernetes Pipelines #
################################################################################################################
#######################################################
# Installing The `codefresh` CLI And Getting The Code #
#######################################################
# Replace `[...]` with the token
codefresh auth \
create-context devops-catalog \
--api-key [...]
open https://github.com/vfarcic/codefresh-cli-examples
# Fork the repo
# Replace `[...]` with the GitHub organization
export GH_ORG=[...]
git clone \
https://github.com/$GH_ORG/codefresh-cli-examples.git
cd codefresh-cli-examples
###########################################
# Setting Up The Kubernetes Prerequisites #
###########################################
cat create-cluster.yaml
kubectl apply \
--filename create-cluster.yaml
############################
# Adding Kubernetes Config #
############################
export CURRENT_CONTEXT=$(\
kubectl config current-context)
codefresh create cluster \
--kube-context $CURRENT_CONTEXT \
--serviceaccount codefresh \
--namespace codefresh
codefresh get clusters
######################
# Adding Git Context #
######################
codefresh get contexts
open https://github.com/settings/tokens
export GH_TOKEN=[...]
echo "export GH_TOKEN=$GH_TOKEN" \
| tee env
cat .gitignore
codefresh create context \
git github devops-catalog \
--access-token $GH_TOKEN
codefresh get contexts
######################
# Creating A Project #
######################
codefresh create project devops-catalog
codefresh get projects
#######################
# Creating A Pipeline #
#######################
cp orig/codefresh.yml .
cat codefresh.yml
cat codefresh.yml \
| sed -e "s@my-cluster@$CURRENT_CONTEXT@g" \
| tee codefresh.yml
codefresh create pipeline \
-f codefresh.yml
codefresh get pipelines
##############################################
# Running Pipeline Builds And Observing Logs #
##############################################
git add .
git commit -m "Adding app of apps"
git push
codefresh get builds \
--pipeline-name codefresh-cli
export BUILD_ID=[...] # e.g., `5f6e10b5c343f14d8b37fd19`
codefresh logs $BUILD_ID -f
##############################
# Destroying What We Created #
##############################
codefresh delete cluster $CURRENT_CONTEXT
codefresh delete context devops-catalog
codefresh delete pipeline \
devops-catalog/codefresh-cli
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment