Wednesday, March 27, 2024 - 11:14
  • Share this article:

You may have already heard of GitHub Copilot, an AI-powered code completion tool developed by GitHub in collaboration with OpenAI. It is designed to accelerate the software development life cycle by offering real-time suggestions for whole lines or blocks of code within your editor. GitHub Copilot is built on a machine-learning model trained on public source code, enabling it to provide contextually relevant code snippets, function implementations, and entire algorithms tailored to your coding projects.

When it comes to deployment, GitHub Copilot becomes especially useful by offering guidance on things a developer may have less familiarity with, including writing deployment scripts, creating configuration files, and executing deployment commands. 

In addition to the standard GitHub Copilot features, GitHub has introduced Copilot Chat, a feature that allows developers to have an interactive conversation with the AI. Copilot Chat is designed to understand more complex, conversational queries and can assist developers by explaining code snippets, suggesting best coding practices, and offering more detailed, conversational assistance during the development process.

Copilot and Copilot Chat can greatly assist developers in many tasks, especially complex ones, such as deploying a Java application to Azure Kubernetes Service (AKS). Copilot can provide recommended Kubernetes configuration snippets, Dockerfile syntax, and Azure CLI scripts, making the deployment more straightforward and error-free. In this article, we’ll explore how Copilot can assist developers throughout the entire process of developing and deploying a cloud-native application.

Simplify Development of Robust Deployment Solutions

By understanding the context of your project and the specifics of your deployment needs, Copilot can suggest entire scripts or parts of scripts, reducing the time and effort needed to create robust deployment solutions. For example, when working with Azure Kubernetes Service (AKS), Copilot can guide you through:

  • Script generation: 
    Start typing your Kubernetes deployment script in your IDE and GitHub Copilot will suggest complete YAML configurations or shell scripts, including deployment configurations, service definitions, and ingress rules.
  • Parameterisation and variables: 
    Copilot can parameterize your Kubernetes objects, via environment variables or ConfigMaps. 
  • Optimisation: 

Receive suggestions on optimising your deployment scripts for better performance, security, and resource utilisation based on Kubernetes best practices.

  • Error handling and validation:
    Highlight syntax errors, misconfigurations, or potential inefficiencies, helping to catch issues early in the development cycle.
  • Integration with other services: 
    Suggest configurations for integrating your Kubernetes deployments with other cloud services, such as Azure SQL Database, Azure Blob Storage, or Azure Active Directory.
  • Documentation and comments:
    Document your deployment scripts with explanations and comments in your YAML files.

Here’s an example of asking for improvements on an existing deployment script in a GitHub CodeSpace: 




Work Faster and Easier With Open Liberty and WebSphere Liberty 

Open Liberty is the most flexible runtime available to Java developers in this solar system. Open Liberty offers a lightweight framework for building fast cloud-native applications using the industrial standards MicroProfile and Jakarta EE. Open Liberty is open source and more details about Open Liberty can be found here. If you have not tried Open Liberty, the following getting started guide will get you started within 30 minutes.

WebSphere Liberty is an IBM product, consisting of Open Liberty and additional functionalities, such as Liberty Collectives and other Java EE technologies. WebSphere Liberty and Open Liberty are released together with the same version scheme.

GitHub Copilot makes it faster and easier to set up and deploy Java applications using Open Liberty or WebSphere Liberty with the following features:

  • Auto-completion for configuration files: 
    When creating or editing Liberty server configuration files, such as `server.xml`, GitHub Copilot can suggest complete XML snippets based on the context of your application and the features you need, ensuring that all necessary configurations are correctly set.
  • Environment-specific configurations:
    Copilot can help tailor your Liberty configurations for different environments (development, testing, production) by suggesting appropriate changes or additions to your Dockerfiles and Kubernetes manifests, ensuring your application runs smoothly in each context.
  • Feature management:
    If you’re unsure about which features to enable for your Liberty application, Copilot      can suggest relevant features and corresponding configuration snippets based on your application’s requirements and dependencies.
  • Troubleshooting and debugging: 
    When you encounter issues with your Liberty configuration, GitHub Copilot can suggest corrections and troubleshooting steps, helping you resolve problems faster and with less frustration.
  • Customisation and extensions: 
    For advanced Liberty configurations, such as custom user registries or specialized logging settings, Copilot can provide code snippets and guidance, helping you extend your Liberty container images beyond the basics.

By leveraging GitHub Copilot for Liberty configuration, developers can reduce the time and effort required to set up and manage Liberty container images, allowing them to focus more on developing and deploying Java applications.

Database Scripting Assistance 

GitHub Copilot can also assist in writing database setup scripts or SQL queries by suggesting code based on the context of your project and your database requirements. This can significantly speed up the process of creating and managing your database schemas, tables, and data.

When building a database inside Docker, GitHub Copilot can help by refining Dockerfile commands to enhance:

  • Efficient layer construction: 
    Copilot can suggest ways to structure your Dockerfile commands to minimise the number of layers, reducing the overall image size and build time. 
  • Security: 
    Copilot compares and recommends specific base images that are known for their security and stability. Suggestions for security best practices include non-root users, minimising the use of privileged operations, and avoiding the inclusion of sensitive data.
  • Dependency management:
    Copilot can guide you through the optimal ways to manage dependencies in your Dockerfile, like caching layers for faster builds or ordering instructions to leverage Docker’s build cache effectively.
  • Environment optimisation:
    Get suggestions for setting environment variables, exposing ports, or configuring volumes in a way that optimises the container environment.
  • Health checks and metrics: 
    Copilot can suggest adding Health Check instructions to ensure your containerised application is running correctly, and it can provide instructions for integrating monitoring tools and metrics.
  • Multi-stage builds: 
    For complex applications, Copilot can guide you through setting up multi-stage builds, separating the build environment from the runtime environment.


Here’s an example of an examination of the Dockerfile in this sample app, as well as some suggested improvements: 



Simplify Initial Deployment and Post-Deployment Management 

GitHub Copilot can aid in creating YAML files or commands for the operator deployment, making it easier to deploy and manage applications in Kubernetes environments. By suggesting the necessary configurations and parameters, Copilot helps ensure your deployments are efficient and error-free.

After deployment, it is crucial to monitor and manage your application to ensure it operates correctly. This includes tracking the performance, identifying and resolving issues, and updating the application as needed.

GitHub Copilot can continuously assist with the writing of monitoring scripts and management commands for maintaining and optimising your application. Whether it’s suggesting logging practices, alert configurations, or performance optimisation commands, Copilot can be a valuable tool in ensuring your application remains healthy and efficient.

Here’s an example of Copilot suggesting ways to monitor and manage this application post-deployment:




Share Your Experiences and Tips for Leveraging GitHub Pilot

In this article, we explored how GitHub Copilot can provide value throughout the various stages of deploying a Java application using Open Liberty and/or WebSphere Liberty on Azure Kubernetes Service. By significantly reducing the complexity and increasing the efficiency of this process, from setting up the environment and writing deployment scripts to post-deployment monitoring and management, AI can reduce errors while helping developers work more quickly and accurately.

We encourage the community to share experiences, improvements, and any tips discovered while using GitHub Copilot and deploying applications on AKS. Your feedback is invaluable.

We’ll also be leading a hands-on session at DevNexus 2024 on how to enable deployments of Jakarta EE applications using Open Liberty or WebSphere Liberty to the cloud, how to streamline containerisation, deployment and provisioning of resources, as well as how to establish a SQL Database connection to the deployed application.

For additional resources and references, have a look at:

About the Author

Brian Benz

Brian Benz

Brian Benz is a Java Champion and a Cloud Advocate at Microsoft.

Emily Jiang

Emily Jiang

Emily Jiang is a Java Champion, Architecture Council Appointee, project lead on the Eclipse Config project, and a mentor and committer on several other projects.